I'm reading german names from a csv, and want to write them in a csv file, with the right encoding for ä, ö and ü. Reading works fine, but when I write to the csv, the characters are displayed like this: Löffler.
reader1 = csv.reader(open('names.csv', 'rb'), delimiter=',')
What do I need to add to my writer to get the right encoding?
outfile.write('K:' + n + ',' + a + ',' + '-' + '\n')
I tried unicodecsv, but can't get it to work:
w = unicodecsv.writer(outfile, encoding='utf-8')
w.write('K:' + n + ',' + a + ',' + '-' + '\n')
Error message:
AttributeError: 'UnicodeWriter' object has no attribute 'write'