[issue39876] csv.DictReader.fieldnames interprets unicode as ascii

Serhiy Storchaka report at bugs.python.org
Fri Mar 6 10:14:24 EST 2020


Serhiy Storchaka <storchaka+cpython at gmail.com> added the comment:

csv.DictReader does not work with encodings. It works with already decoded strings.

You have to specify the correct encoding in open() (and "t" in mode is ignored):

with open(filename, "r", encoding="utf-8") as csvfile:

By default open() uses locale encoding. It is likely 'cp1252' on American and Western European Windows.

----------
nosy: +serhiy.storchaka
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue39876>
_______________________________________


More information about the Python-bugs-list mailing list