我试图解析这样的文本日志文件,我可以使用默认的read.csv来解析这个文件。
test < - read.csv(“test.txt”,header = FALSE)
它将所有逗号分隔,虽然没有完美地放在数据框中,但可以进行进一步的操作来改进。 但是,我似乎无法使用readr包这样做
test < - read_csv(“test.txt”,header = FALSE)
所有观察结果都变为1行,逗号之间没有分离。 我正在学习这个包,所以任何帮助都会很棒。
{ “的dev_id”: “F8:F0:05:XX:分贝:XX”, “数据”:[{ “DIST”:[7270,7269,7269,7275,7270,7271,7265,7270,7274,7267, 7271,7271,7266,7263,7268,7271,7266,7265,7270,7268,7264,7270,7261,7260]},{ “温度”:0},{ “嗡嗡”:0},{ “VIN” :448}],“time”:4485318,“transmit_time”:4495658,“version”:“1.0”} {“dev_id”:“f8:xx:05:xx:d9:xx”,“data”:[{ “DIST”:6869,6868,6867,6871,6866,6867,6863,6865,6868,6869,6868,6860,6865,6866,6870,6861,6865,6868,6866,6864,6866,6866,6865 ,6872]},{ “温度”:0},{ “嗡嗡”:0},{ “VIN”:449}], “时间”:4405316, “transmit_time”:4413715, “版本”: “1.0”} { “的dev_id”: “XX:F0:05:E8:DA:XX”, “数据”:[{ “DIST”:[5775,5775,5777,5772,5777,5770,5779,5773,5776,5777, 5772,5768,5782,5772,5765,5770,5770,5767,5767,5777,5766,5763,5773,5776]},{ “温度”:0},{ “嗡嗡”:0},{ “VIN” :447}],“time”:4461316,“transmit_time”:4473307,“version”:“1.0”} {“dev_id”:“xx:f0:xx:e8:xx:0a”,“data”:[{ “DIST”:4358,4361,4355,4358,4359,4359,4361,4358,4359,4360,4360,4361,4361,4359,4359,4356,4357,4361,4359,4360,4358,4358,4362 ,4359]},{ “温度”:0},{ “嗡嗡”:0},{ “VIN”:424}], “时间”:5190320,“TRAN smit_time “:5198748,” 版本 “:” 1.0" }
感谢@ Dave2e指出这个文件是JSON格式,我找到了使用ndjson :: stream_in解析它的方法。