using DictReader() with .decode('utf-8', 'ignore')

Michiel Overtoom motoom at xs4all.nl
Tue Apr 14 15:15:32 CEST 2015


> ​How can I ​do accomplish decode('utf-8', 'ignore') when reading with DictReader()

Have you tried using the csv module in conjunction with codecs?
There shouldn't be any need to 'ignore' characters.


    import csv
    import codecs

    rs = csv.DictReader(codecs.open(fn, "rbU", "utf8"))
    for r in rs:
	print(r)

Greetings,

-- 
"You can't actually make computers run faster, you can only make them do less." - RiderOfGiraffes




More information about the Python-list mailing list