Reputation: 1
I imported a json file from google drive to Colab like this
downloaded = drive.CreateFile({'id':'XXX'}) downloaded.GetContentFile('All_Beauty.json')
and when I try reading the file with
import pandas as pd
beauty_df = pd.read_json('All_Beauty.json')
beauty_df.head()
I get this error:
ValueError Traceback (most recent call last)
<ipython-input-15-1acb00f4feed> in <module>()
----> 1 beauty_df = pd.read_json('All_Beauty.json')
2 beauty_df.head()
5 frames
/usr/local/lib/python3.6/dist-packages/pandas/io/json/_json.py in _parse_no_numpy(self)
1087 if orient == "columns":
1088 self.obj = DataFrame(
-> 1089 loads(json, precise_float=self.precise_float), dtype=None
1090 )
1091 elif orient == "split":
ValueError: Trailing data
Any idea of what is going wrong? Many thanks
Upvotes: 0
Views: 8019
Reputation: 2305
It sounds like you have several lines in your json file.
you probably need to use the lines
argument:
beauty_df = pd.read_json('All_Beauty.json', lines=True)
Upvotes: 1