As the documentation says, in a big Note near the top:
This version of the csv module doesn’t support Unicode input. Also, there are currently some issues regarding ASCII NUL characters. Accordingly, all input should be UTF-8 or printable ASCII to be safe; see the examples in section Examples.
If you follow link to the example, it shows you the solution: Encode each line to UTF-8 before passing it to csv
. They even give you a nice wrapper, so you can just replace the csv.reader
with unicode_csv_reader
and the rest of your code is unchanged:
csvReader = unicode_csv_reader(codecs.open('/home/kuberkaul/Downloads/csv.csv', 'rb', 'utf-16'))
for row in csvReader:
print row
Of course the print
isn't going to be very useful, as the str
of a list uses the repr
of each element, so you're going to get something like [u'foo', u'bar', u'\u0910\u0911']
…
You can fix that in the usual ways—e.g., print u', '.join(row)
will work if you remember the u
, and if Python is able to guess your terminal's encoding (which it can on Mac and modern linux, but may not be able to on Windows and old linux, in which case you'll need to map an explicit encode
over each column).