本文介绍了除了下面的方法,还有其他方法可以将json.rows文件加载到RStudio中吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个json.rows文件->具有大约223k行的instance.json.rows

I have a json.rows file -> instances.json.rows with approximately 223k rows

我尝试使用jsonlite并想出了

I tried using jsonlite and came up with

instancesfile <- fromJSON("instances.json.rows")

但是我一直遇到错误

Error in parse_con(txt, bigint_as_char) : parse error: trailing garbage
      kcBy-cs", "time_type": "in"} {"cluster_ids": ["Bz4SOc6zZn0"]
                 (right here) ------^

这是文件第一行中数据的图像.抱歉,如果我的问题不够清楚.在评论中让我知道,我将根据需要编辑我的问题.预先谢谢你!

Here is an image of the data from the first row of my file. Apologies if my question is not clear enough. Let me know in the comments and I will edit my question as required. Thank you in advance!

推荐答案

out <- lapply(readLines("instances.json.rows"), fromJSON)

恭喜,这就是您想要的. L apply将fromJSON函数应用于从readLines返回的每个成员,并将结果返回给out.我的评论中有些想念Spoke,要使您的文件有效为json,您必须用逗号替换换行符,然后在以下示例中将结果放在*处.但这完全是无稽之谈,只需使用上面的一根衬纸即可.

Congrats out is what you want it to be. The L apply applies the fromJSON function to each member returned from readLines and returns the results to out. I miss Spoke a bit in my comment, to make your file valid json you would have to replace the newlines with comma, then put the result where the * is in the below example. But that's all non-sense, just use the above one liner.

{"data":[*]}

这篇关于除了下面的方法,还有其他方法可以将json.rows文件加载到RStudio中吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-30 12:53