'Json UnicodeDecodeError 'charmap' codec can't decode byte 0x8d in position 3621: character maps to <undefined>
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!
Solution 1:[1]
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>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Herman Autore |