I have a Json file as follows. It's a list of dicts.
[{"city": "ab", "trips": 4, "date": "2014-01-25", "value": 4.7, "price": 1.1, "request_date": "2014-06-17", "medium": "iPhone", "%price": 15.4, "type": true, "Weekly_pct": 46.2, "avg_dist": 3.67, "avg_price": 5.0}, {"city": "bc", "trips": 0, "date": "2014-01-29", "value": 5.0, "price": 1.0, "request_date": "2014-05-05", "medium": "Android", "%price": 0.0, "type": false, "weekly_pct": 50.0, "avg_dist": 8.26, "avg_price": 5.0}.....]
When I read this using this:
data=pd.read_json('dataset.json')
I get the following error:
ValueError: Expected object or value
I tried this too:
from ast import literal_eval
with open('dataset.json') as f:
data = literal_eval(f.read())
df = pd.DataFrame(data)
It gives the following error:
ValueError: malformed string
Edit:
Even Json.loads doesn't work. Tried this:
import json
data=json.loads('dataset.json')
ValueError: No JSON object could be decoded
The Json file is 13.5MB but it seems to have huge amounts of data.
See Question&Answers more detail:
os