Reputation: 1126
I'm loading a json file on my computer. I can load it in without specifying the encoding on Kaggle, no, errors. On my PC I get the error in the title.
with open('D:\soccer\statsbomb360\matches.json') as f:
data = json.load(f, encoding = 'utf8')
Adding errors = 'ignore'
or changing encoding to 'latin' doesn't work either.
I'm a bit lost on what to try next, can you give me an idea?
The json is from statsbombs freely available data.
Interestingly from the same dataset I have some files that give me this error on Kaggle/Colab but not on my pc, but there specifying encoding = 'latin'
did the trick.
thank you!
Upvotes: 4
Views: 7114
Reputation: 180
Try
with open('D:\soccer\statsbomb360\matches.json', encoding="utf8") as f:
data = json.load(f)
per @mark-tolonen
Also see this post: UnicodeDecodeError: 'charmap' codec can't decode byte X in position Y: character maps to <undefined>
Upvotes: 9