Unicodedecodeerror: 'Charmap' Codec Can't Decode Byte X in Position Y: Character Maps to ≪Undefined≫

UnicodeDecodeError: 'charmap' codec can't decode byte X in position Y: character maps to <undefined>

The file in question is not using the CP1252 encoding. It's using another encoding. Which one you have to figure out yourself. Common ones are Latin-1 and UTF-8. Since 0x90 doesn't actually mean anything in Latin-1, UTF-8 (where 0x90 is a continuation byte) is more likely.

You specify the encoding when you open the file:

file = open(filename, encoding="utf8")

#'charmap' codec can't decode byte 0x8d in position 1148

When you use open(), you also use a default encoding. It most likely didn't fit you. Try using something like -
with open(os.path.join(path,item),"r",encoding='utf8')
Or, if you can, check what is the enryption which was used on this file.

Try to check the answers this post, one of them might help you.

UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 2433: character maps to <undefined>

Just add encoding='utf-8' within .read_text():

paragraph = Path('myfile.txt').read_text(encoding='utf-8')

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

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>



Related Topics



Leave a reply



Submit