If someone could tell me why when converting a csv file separated by | , it throws me the error:
File "D:\XXXXXXX\XXXXXXX\extraccion_unica.py", line 32, in ObtenerUnica
for row in reader:
File "C:\Program Files (x86)\Python310-32\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 0x8d in position 7307: character maps to <undefined>
I have the doubt if it is when specifying the delimiter '|', this is my code:
wb = openpyxl.Workbook()
ws = wb.active
with open("D:/XXXXXXX/ResCargueUnica"+archivo_dia+".csv") as f:
reader = csv.reader(f,delimiter = '|')
for row in reader:
ws.append(now)
wb.save('ResCargueUnica'+archivo_dia+'.xlsx')
Try adding
, encoding='utf-8'
to the file reading configuration