csv read _csv.Error: line contains NULL byte

chip9munk at gmail.com chip9munk at gmail.com
Fri Mar 21 09:29:56 EDT 2014


Hi all!

I am reading from a huge csv file (> 20 Gb), so I have to read line by line:

for i, row in enumerate(input_reader):
      #  and I do something on each row

Everything works fine until i get to a row with some strange symbols "0I`00�^"
at that point I get an error: _csv.Error: line contains NULL byte

How can i skip such row and continue going, or "decipher" it in some way?

I have tried :
csvFile = open(input_file_path, 'rb')
csvFile = open(input_file_path, 'rU')
csvFile = open(input_file_path, 'r')

and nothing works.

if I do:

try:
    for i, row in enumerate(input_reader):
      #  and I do something on each row
except Exception:
    sys.exc_clear() 

i simply stop an that line. I would like to skip it and move on.

Please help!

Best,

Chip Munk



More information about the Python-list mailing list