I have a text/html file with 158 row and 25 column data in JSON format and I have been trying to convert it into a dataframe so that I could write it in .csv. I have tried "rjson" and 'jsonlite' packages to read the data and then use convert it into datatable by two approach
Use
library(jsonlite) json_file = "projectslocations.html" json_datan <- fromJSON(json_file)
The data structure has only one row with 158 variables
2.using jsonlite and data.table
library(jsonlite)
library(data.table)
json_dat <- fromJSON(json_file)
class(json_dat)
lst= rbindlist(json_dat, fill=TRUE)
This shows data.frame with 158 rows and 25 variables. However I cant write this dataframe in csv or even view the dataframe.
error :
Error in FUN(X[[i]], ...) :
Invalid column: it has dimensions. Can't format it. If it's the result of data.table(table()), use as.data.table(table()) instead.
The original data is available here
P108941: {...}. If the file was just an array of unnamed docs - e.g.[{...}, {...}]your life would be easier (I think).locationsfield, which is often an array of docs containing location information, as a single column in a CSV file?