简体   繁体   中英

Unmatched ''"' when when decoding 'string' error in reading json file into pandas dataframe

I am trying to load a amazon review data into pandas dataframe, which is a JSON file , using the pd.read_json(), I am getting the following error Unmatched ''"' when when decoding 'string'. I am using jupyter notebook

Data format:

{"reviewerID": "AGL65XWV7MH3C", "asin": "B003FMUVKO", "reviewerName": "William B. Bebout \"Acknud\"", "helpful": [0, 1], "reviewText": "Too short. I would have rated it higher if it was long enough to hold my attention! It did have significant violence but not much else.", "overall": 3.0, "summary": "Short", "unixReviewTime": 1304985600, "reviewTime": "05 10, 2011"}

Python code:

data =pd.read_json('sample_data.json', lines=True)

I just had the same error and after trying every possible solution the simple fix was to remove the empty line at the end of the file.

Leaving an empty line at the end of a file is a common convention but seems to choke pandas for some reason,

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM