0

I'm running this:

table = petl.fromcsv('file.txt', delimiter = ',' , encoding = 'utf-8) 
petl.todb(table, connection, 'table') 

And i am getting this error on insert step:

File "/usr/local/lib/python2.7/dist-packages/petl/util/base.py", line 28, in __len__ 
 return sum(1 for _ in self) 
 File "/usr/local/lib/python2.7/dist-packages/petl/util/base.py", line 28, in <genexpr> 
 return sum(1 for _ in self) 
 File "/usr/local/lib/python2.7/dist-packages/petl/io/csv_py2.py", line 45, in __iter__ 
 for row in reader: 
 File "/usr/local/lib/python2.7/dist-packages/petl/io/csv_py2.py", line 149, in next 
 row = self.reader.next() 
_csv.Error: line contains NULL byte

What i can to do to solve this problem?

Dimgold
  • 2,748
  • 5
  • 26
  • 49
gabriel.almeida
  • 125
  • 1
  • 2
  • 11
  • What's `petl`? it seems that you need to open your file in binary mode. Does the `fromcsv` method accept an opening mode? – Mazdak Jun 27 '16 at 13:41
  • petl is a general purpose Python package for extracting, transforming and loading tables of data. More: https://petl.readthedocs.io/en/latest/ – gabriel.almeida Jun 27 '16 at 13:45

0 Answers0