我有一段时间从一个名为" D:/ myjsonShort"的文本文件中将以下JSON读入R数据帧。在Windows 10.我尝试使用带有fromJSON函数的RJSONIO
,jsonlite
和rjson
软件包,但似乎无法阅读此内容。我想阅读此内容所以我的数据框将包含变量:" volumne"," timestamp"," high"," low",'等。
[{u'volume': u'0', u'timestamp': Decimal('0'), u'high': u'0', u'low': u'0', u'quoteVolume': u'0', u'close': u'0', u'weightedAverage': u'0', u'open': u'0', u'market': u'POLO-BTC_REP'},
{u'volume': u'0.02202444', u'timestamp': Decimal('1494050400'), u'high': u'0.01101223', u'low': u'0.01101222', u'quoteVolume': u'2', u'close': u'0.01101223', u'weightedAverage': u'0.01101222', u'open': u'0.01101222', u'market': u'POLO-BTC_REP'},
{u'volume': u'0.00363405', u'timestamp': Decimal('1494050700'), u'high': u'0.0110123', u'low': u'0.0110123', u'quoteVolume': u'0.33', u'close': u'0.0110123', u'weightedAverage': u'0.0110123', u'open': u'0.0110123', u'market': u'POLO-BTC_REP'}]
这是我尝试的一些代码,但这最终会返回一个空字符串列表:
library(RJSONIO)
a<-fromJSON("D:/myjsonShort.txt")
a
然后返回:
[[1]]
[[1]]$`'volume`
NULL
[[1]]$`'timestamp`
NULL
[[1]]$`'high`
NULL
[[1]]$`'low`
NULL
[[1]]$`'quoteVolume`
NULL
[[1]]$`'close`
NULL
[[1]]$`'weightedAverage`
NULL
[[1]]$`'open`
NULL
[[1]]$`'market`
NULL
[[2]]
[[2]]$`'volume`
NULL
[[2]]$`'timestamp`
NULL
[[2]]$`'high`
NULL
[[2]]$`'low`
NULL
[[2]]$`'quoteVolume`
NULL
[[2]]$`'close`
NULL
[[2]]$`'weightedAverage`
NULL
[[2]]$`'open`
NULL
[[2]]$`'market`
NULL
[[3]]
[[3]]$`'volume`
NULL
[[3]]$`'timestamp`
NULL
[[3]]$`'high`
NULL
[[3]]$`'low`
NULL
[[3]]$`'quoteVolume`
NULL
[[3]]$`'close`
NULL
[[3]]$`'weightedAverage`
NULL
[[3]]$`'open`
NULL
[[3]]$`'market`
NULL
任何想法如何解决这个问题?