I am trying to read a bzip2-compressed CSV file in Python 3.2. For an uncompressed CSV file, this works:
datafile = open(\'./file.csv\', mode=\'rt\') data =
This works for me:
import codecs, csv f = codecs.open("file.csv", "r", "utf-8") g = csv.reader(f) for e in g: print(e)
In the case of BZ2:
import codecs, csv, bz2 f = bz2.BZ2File("./file.csv.bz2", mode="r") c = codecs.iterdecode(f, "utf-8") g = csv.reader(c) for e in g: print(e)