csv read _csv.Error: line contains NULL byte

chip9munk at gmail.com chip9munk at gmail.com
Fri Mar 21 10:46:00 EDT 2014


On Friday, March 21, 2014 2:39:37 PM UTC+1, Tim Golden wrote:

> Without disturbing your existing code too much, you could wrap the
> 
> input_reader in a generator which skips malformed lines. That would look
> 
> something like this:
> 
> 
> 
> def unfussy_reader(reader):
> 
>     while True:
> 
>         try:
> 
>             yield next(reader)
> 
>         except csv.Error:
> 
>             # log the problem or whatever
> 
>             continue


I am sorry I do not understand how to get to each row in this way.

Please could you explain also this:
If I define this function, 
how do I change my for loop to get each row?

Thanks!



More information about the Python-list mailing list