UnicodeEncodeError: 'charmap' codec can't encode character '\u4e00' in position 28: character maps to <undefined>

Viewed 14

I am trying to decode a .csv in python. But the .csv has Chinese eg.(三) and Japanese eg.(さん) characters in it

Here is how i am decoding the file:

fname = "data.csv"

rows = []
with open(fname, 'r', encoding="utf-8") as file:
    csvreader = csv.reader(file)
    for row in csvreader:
        rows.append(row)
    print(rows)

It gives me this error even thought its already decoded with utf-8:

Traceback (most recent call last):
  File "c:\Users\m8\Desktop\programing_stuff\python-stuff\handwritten_kanji_recognition - 30-08-2022\app.py", line 25, in <module>
    print(rows)
  File "C:\Users\m8\AppData\Local\Programs\Python\Python310\lib\encodings\cp1252.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\u4e00' in position 28: character maps to <undefined>
0 Answers
Related