Loading JSON data

User 922 | 11/13/2014, 5:53:19 PM

I have come across another post asking for more information about how to read in JSON, without any anwsers. I am having difficulty reading in JSON. The error I get is Runtime Exception: 0, Unable to parse sframe index file ./file.json

Coming from line 452 of sframe.pyc.

my json has the following format {"A":[{B:[{"V":{"adf":null,"fd":"asdf"},"c":"asdf","d":"asdf"},...],"B": ...}]}

I don't see any documentation on dealing with json, any help is appreciated. Thank you.

Comments

User 4 | 11/14/2014, 2:51:53 AM

Try <a href="http://graphlab.com/products/create/docs/generated/graphlab.SFrame.readcsv.html">SFrame.readcsv</a> (despite the name, it is capable of reading more than just CSV-format files). It may read each line into a single column: you can then use <a href="http://graphlab.com/products/create/docs/generated/graphlab.SFrame.unpack.html">SFrame.unpack</a> to expand the key/value pairs into multiple columns.


User 922 | 12/5/2014, 8:36:05 PM

Thanks I will give it a go


User 4 | 12/5/2014, 8:37:47 PM

See also the how-to on this: https://github.com/graphlab-code/how-to/blob/master/load_json.py