无与伦比的''''什么时候解码'字符串'将json文件读入pandas数据帧时出错

时间:2018-04-29 01:18:43

标签: python pandas jupyter-notebook

我正在尝试将亚马逊评论数据加载到pandas dataframe,这是一个JSON文件,使用pd.read_json(),我收到以下错误Unmatched ''"' when when decoding 'string'.我正在使用jupyter notebook

数据格式:

{"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代码:

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

1 个答案:

答案 0 :(得分:0)

我只是遇到了同样的错误,尝试了所有可能的解决方案后,简单的解决方法是删除文件末尾的空行。

在文件末尾留空行是一种常见的约定,但由于某种原因似乎使熊猫窒息了,