How to import a one lined flat file .txt with much information in R

29 Views Asked by At

my test.txt file looks like this

"Nr" | | "X1" | | "ID_T20" | | "Herstellernummer" | | "Werksnummer" | | "Fehlerhaft" "1" | | 1 | | "20-211-2111-14" | | "211" | | "2111" | | 0

I tried a lot of commands to import it as a data frame like this:

 "Nr" , "X1" , "ID_T20"         , "Hersteller" , "Werksnummer" , "Fehlerhaft"

 "1" ,   1  , "20-211-2111-14" , "211"        , "2111"        ,0

can you help me?

1

There are 1 best solutions below

0
Adam Waring On

Possibly:

x = strsplit(readLines(x), "\\|\\|")[[1]]
x = data.frame(x, stringsAsFactors=F)