我想在R中读取或转换为CSV文件中的大型JSON文件(2Gb)。我几乎尝试了这个博客和其他人的一切,直到现在我才能成功。
JSON文件与Yelp Round 7 Challenge相关,您可以通过以下链接下载。 https://www.yelp.co.uk/dataset_challenge
我使用了普通的rjson库,我收到了以下错误:
> library(rjson)
> df <- fromJSON(file = "yelp_dataset_challenge_academic_dataset.json")
Error in fromJSON(file = "yelp_dataset_challenge_academic_dataset.json") : unexpected character 'D'`
答案 0 :(得分:0)
您遇到的错误是什么?例如,使用this JSON数据:
使用 rjson 库加载初始json文件:
df <- fromJSON(file = "path/to/miserables.json")
你需要做一些工作来解决它:
names <- unlist(lapply(df$nodes, function(x){x$name}))
groups <- unlist(lapply(df$nodes, function(x){x$group}))
final.df <- data.frame(names,groups)