0

I keep receiving the following error message "csv.Error: line contains NULL byte " when trying to read my gzip file contains NULLs at the header and end of file and I'm trying to figure out a way to skip these but cannot get past the error message. Has anyone come across this and has a solution?

from gzip import GzipFile
import csv
import codecs

gzipped = GzipFile(None, 'rb', fileobj=response['Body'])
lines = csv.reader(codecs.iterdecode(gzipped, 'utf-8'))
print (lines, "lines")

next(lines) #to skip header

Error: _csv.Error: line contains NULL byte

I can't also use pandas lib as this lib is not available within the platform I am working on. Only basic python libs are available.

Barmar
  • 741,623
  • 53
  • 500
  • 612

0 Answers0