I am trying to write characters with double dots (umlauts) such as ä, ö and Ö. I am able to write it to the file with
with open("test.csv", "w") as fp:
a = csv.writer(fp, delimiter=";")
File "<ipython-input-280-73b1f615929e>", line 5, in <module>
UnicodeEncodeError: 'ascii' codec can't encode character '\xe4' in position 15: ordinal not in range(128)
io.open from the
io library, where you can set the encoding.
import io import csv data = "ääÖ" with io.open("test.csv", 'w', encoding='utf8') as fp: a = csv.writer(fp, delimiter=";") a.writerows(data)