Csv Reader: Line Contains Null Byte
Solution 1:
The csv
module contains the following warning:
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.
The StringIO.StringIO
object supports unicode, but if you are using the cStringIO
module, then cStringIO.StringIO
doesn't, and can lead to more problems.
If your data is ASCII only, simply encode txt
first:
txt = txt.encode()
There could have been some fixes added to 2.7.3 that make the problem less visible.
Solution 2:
csv module has problems reading data from Unicode encoded files. Your code worked when I pasted it into the python interpreter and called it with a manually entered text string, so it should work if you try saving the file in ANSI/ASCII format, or converting it to ASCII when loading it into memory.
Post a Comment for "Csv Reader: Line Contains Null Byte"