Created
May 23, 2014 14:56
-
-
Save sboisson/0272707f96bd17ed976c to your computer and use it in GitHub Desktop.
Correctly reading CSV files in arbitrary encodings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import codecs | |
import csv | |
def csv_unireader(f, encoding="utf-8"): | |
for row in csv.reader(codecs.iterencode(codecs.iterdecode(f, encoding), "utf-8")): | |
yield [e.decode("utf-8") for e in row] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment