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

Viewed 39

I have this code, that merged some txt file from a folder.

CODE

import fileinput
import glob
import os
import re
with open('c:\\Folder6\\merged.txt', 'w', encoding='UTF-8') as f:
    
    for line in fileinput.input(glob.glob('c:\\Folder6\\translated\\en\\*.txt')):
        f.write(line)
    fileinput.close()

I get this ERROR on running code:

  File "C:\Program Files\Python39\lib\encodings\cp1252.py", line 23, in decode
    return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 2292: character maps to <undefined>

What is the solution?

0 Answers
Related