petl-developers/petl

Handle null bytes when reading from CSVs

rayeschiller opened this issue · 1 comments

Feature request

Petl doesn't handle null bytes when reading from CSV with etl.fromcsv and throws a csv error: line contains NULL byte

We have a workaround to manually read from the old file and write to a new file and replace the null bytes with empty strings line by line, but is there a way for Petl to handle this?

Using petl installed by pip, v1.7.2

Hi @rinaschiller ,

  • In the fromcsv case, it's only used standard python modules like io and csv.
    • So I think there is room for improvement.
    • You can check how it works in this point in the source code (and this one for python2).
  • I'm open to any improvement that doesn't impact performance, portability, and manutenabiltiy.
    • So patches welcome.
  • Additionally, have you tried to open the file before and pass the filehandle for fromcsv? Does this work with your workaround?