I'm writing a script that needs to look up some a value in a CSV file. The CSV file is from an external resource and I don't have much control about the file. So basically, I need to work with the CSV file that is presented to me and I need to deal with that.
Now when I read the CSV file (containing 30.000 rows at the moment), the script crashes at a certain point. It returns this error:
File "C:\Python34\lib\encodings\cp437.py", line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_map)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\u0161' in position 55: character maps to <undefined>
My python code for reading the CSV file:
import csv
with open('mybigfile.csv') as f:
reader = csv.reader(f, delimiter=';')
for row in reader:
print(row)
How would I be able to fix this so it can handle the encoding of the file.