Home > database >  Json Decoder Error when reading from JSON file in Python
Json Decoder Error when reading from JSON file in Python

Time:06-13

I am trying to read a JSON file(17MB) stored in the google drive into collaboratory. Here is the code:

import json
with open('GOOGLEDRIVE_FILEPATH/FILE_NAME.json',encoding="utf-8-sig") as f:
  data=json.load(f)

But data=json.load(f) results in a JSONDecodeError: JSONDecodeError: Extra data: line 1 column 177193 (char 177192) The JSON file is of the format:

[{ "id":1,
    "name": "Joe" 
},{"id":2,
    "name": "Jane" },
.
.
{"id": xxx,
    "name": "xxx" }
]

What could be the possible reason for such an error?

CodePudding user response:

This issue was resolved by removing stray characters in the JSON file that crept into the file during the append operation.

  • Related