Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Json UnicodeDecodeError 'charmap' codec can't decode byte 0x8d in position 3621: character maps to <undefined>

Tags:

python

json

utf-8

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!

like image 260
Olli Avatar asked Sep 03 '25 03:09

Olli


1 Answers

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>

like image 63
Herman Autore Avatar answered Sep 04 '25 15:09

Herman Autore