I am trying to convert a json file into a table format where I have the distinct fields in the first row and the corresponding data for those fields in the rest of the rows.
converting my json to text, this is what the data looks like (just a small sample to add some context)
{"business_id": "O_X3PGhk3Y5JWVi866qlJg", "full_address": "1501 W Bell Rd\nPhoenix, AZ 85023", "hours": {"Monday": {"close": "18:00", "open": "11:00"}, "Tuesday": {"close": "18:00", "open": "11:00"}, "Friday": {"close": "18:00", "open": "11:00"}, "Wednesday": {"close": "18:00", "open": "11:00"}, "Thursday": {"close": "18:00", "open": "11:00"}, "Sunday": {"close": "18:00", "open": "11:00"}, "Saturday": {"close": "18:00", "open": "11:00"}}, "open": true, "categories": ["Active Life", "Arts & Entertainment", "Stadiums & Arenas", "Horse Racing"], "city": "Phoenix", "review_count": 29, "name": "Turf Paradise Race Course", "neighborhoods": [], "longitude": -112.0923293, "state": "AZ", "stars": 4.0, "latitude": 33.638572699999997, "attributes": {"Take-out": false, "Wi-Fi": "free", "Good For": {"dessert": false, "latenight": false, "lunch": false, "dinner": false, "brunch": false, "breakfast": false}, "Noise Level": "average", "Takes Reservations": true, "Has TV": true, "Delivery": false, "Ambience": {"romantic": false, "intimate": false, "touristy": false, "hipster": false, "divey": false, "classy": false, "trendy": false, "upscale": false, "casual": false}, "Parking": {"garage": false, "street": false, "validated": false, "lot": true, "valet": true}, "Wheelchair Accessible": true, "Outdoor Seating": true, "Attire": "casual", "Alcohol": "full_bar", "Waiter Service": true, "Accepts Credit Cards": true, "Good for Kids": false, "Good For Groups": true, "Price Range": 2}, "type": "business"}
I am having some trouble with the initial code:
import json
data=json.load(open('yelp_academic_dataset_user.json'))
I get the following error.
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-20-fbf46968052d> in <module>()
1
2 import json
----> 3 data=json.load(open('yelp_academic_dataset_user.json'))
C:\Users\ankit.gadodia\AppData\Local\Continuum\Anaconda\lib\json\__init__.pyc in load(fp, encoding, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw)
288 parse_float=parse_float, parse_int=parse_int,
289 parse_constant=parse_constant, object_pairs_hook=object_pairs_hook,
--> 290 **kw)
291
292
C:\Users\ankit.gadodia\AppData\Local\Continuum\Anaconda\lib\json\__init__.pyc in loads(s, encoding, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw)
336 parse_int is None and parse_float is None and
337 parse_constant is None and object_pairs_hook is None and not kw):
--> 338 return _default_decoder.decode(s)
339 if cls is None:
340 cls = JSONDecoder
C:\Users\ankit.gadodia\AppData\Local\Continuum\Anaconda\lib\json\decoder.pyc in decode(self, s, _w)
367 end = _w(s, end).end()
368 if end != len(s):
--> 369 raise ValueError(errmsg("Extra data", s, end, len(s)))
370 return obj
371
ValueError: Extra data: line 2 column 1 - line 70818 column 1 (char 259 - 26982351)
Could someone explain how I can rectify this or some other way to start. All other examples I have seen so far involve the json.load function. I even tried the file.read() function but that is giving an error too