jsonrdata-import

Is there a way other than below to load a json.rows file into RStudio?


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

I tried using jsonlite and came up with

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

But i kept getting an error

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!


Solution

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

    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":[*]}