如何在R中导入带有很多信息的单行平面文件.txt

时间:2019-02-21 12:01:46

标签: r flat-file flatfilereader

我的test.txt文件如下所示

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

我尝试了很多命令将其作为数据框导入,如下所示:

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

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

你能帮我吗?

1 个答案:

答案 0 :(得分:0)

可能:

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