library(rjson)
filenames <- list.files(pattern="*.json") # gives a character vector, with each file name represented by an entry
现在我想将所有JSON文件作为单个dataFrame导入到R中。我该怎么做?
我第一次尝试
myJSON <- lapply(filenames, function(x) fromJSON(file=x)) # should return a list in which each element is one of the JSON files
但上面的代码需要时间来终止,因为我有15,000个文件,我知道它不会返回单个数据帧。有更快的方法吗?
示例JSON文件:
{"Reviews": [{"Ratings": {"Service": "4", "Cleanliness": "5"}, "AuthorLocation": "Boston", "Title": "\u201cExcellent Hotel & Location\u201d", "Author": "gowharr32", "ReviewID": "UR126946257", "Content": "We enjoyed the Best Western Pioneer Square....", "Date": "March 29, 2012"}, {"Ratings": {"Overall": "5"},"AuthorLocation": "Chicago",....},{...},....}]}
答案 0 :(得分:1)
通过以下方式并行:
Years = pd.DataFrame({'Years': range(1900,2000,1)})
答案 1 :(得分:1)
对于那些正在寻找purrr / tidyverse解决方案的人来说:
U