80754

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

Question:

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!

<img class="b-lazy" data-src="https://i.stack.imgur.com/qwrUv.png" data-original="https://i.stack.imgur.com/qwrUv.png" src="https://etrip.eimg.top/images/2019/05/07/timg.gif" />

Answer1:

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

Recommend

  • make m4 see macro when macro ends with same character as string following macro
  • Can I use preg_replace to strip the trailing \\n in multiline mode?
  • auto layout leading or trainling -16
  • Custom URI routing by query string with CodeIgniter?
  • Hatch area using pcolormesh in Basemap
  • java.net.SocketTimeoutException on embedded tomcat with jersey
  • Why isn't \\\\ interpreted as a blackslash in this regex?
  • Get all existing pointers to an object
  • Java Garbage collection, setting reference to null
  • NRefactory: How do I access unresolved Named Arguments on a Property Attribute?
  • Where these are stored?
  • How to display special characters in SQL server 2008?
  • Add dynamic data to line chart from mysql database with highcharts
  • Row to Column conversion in Talend
  • PLSQL: Get number of records updated vs inserted when a merge statement is used
  • Low TTL with Leveled Compaction, should I reduce gc_grace_seconds to improve read performance withou
  • Query to find the duplicates between the name and number in table
  • gspread or such: help me get cell coordinates (not value)
  • How can I enlarge video fullscreen without the affected interface project in as3?
  • MongoDb aggregation
  • Python urlparse: small issue
  • FileReader+canvas image loading problem
  • Java Scanner input dilemma. Automatically inputs without allowing user to type
  • Master page gives error
  • recyclerView does not call the onBindViewHolder when scroll in the view
  • Display Images one by one with next and previous functionality
  • align graphs with different xlab
  • Unanticipated behavior
  • using conditional logic : check if record exists; if it does, update it, if not, create it
  • Hits per day in Google Big Query
  • FormattedException instead of throw new Exception(string.Format(…)) in .NET
  • embed rChart in Markdown
  • Linking SubReports Without LinkChild/LinkMaster
  • python draw pie shapes with colour filled
  • Can't mass-assign protected attributes when import data from csv file
  • sending mail using smtp is too slow
  • XCode 8, some methods disappeared ? ex: layoutAttributesClass() -> AnyClass
  • How to get NHibernate ISession to cache entity not retrieved by primary key
  • How can I use `wmic` in a Windows PE script?
  • Unable to use reactive element in my shiny app