【发布时间】:2016-09-08 21:35:39
【问题描述】:
我有一个具有这种结构的 .txt 文件
section1#[{"p": "0.999834", "tag": "MA"},{"p": "1", "tag": "MO"},...etc...}]
section1#[{"p": "0.9995", "tag": "NC"},{"p": "1", "tag": "FL"},...etc...}]
...
section2#[{"p": "0.9995", "tag": "NC"},{"p": "1", "tag": "FL"},...etc...}]
我正在尝试通过使用 R 和命令来阅读它
library(jsonlite)
data <- fromJSON("myfile.txt")
但我明白了
Error in feed_push_parser(readBin(con, raw(), n), reset = TRUE) :
lexical error: invalid char in json text.
section2#[{"p": "0.99
(right here) ------^
如何分节阅读?
【问题讨论】:
-
您可能需要使用
readLines手动读取文件,删除section部分,然后将其传递给fromJSON。 -
是什么生成了这样的文件?
-
来自mySQL
-
你在 mySQL 中运行什么命令会产生这种疯狂的格式?