1

I am trying to read a csv file. Here is my code:

import csv
openFile = open('example.csv')
fileRead = csv.reader(openFile)
fileRead = list(fileRead)
print fileRead[0]

I am getting this error:

Traceback (most recent call last):
  File "C:/Users/bob/PycharmProjects/Random/random.py", line 5, in <module>
    fileRead = list(fileRead)
_csv.Error: line contains NULL byte
ALUW
  • 397
  • 1
  • 5
  • 15
  • 3
    `csv` package does not support binary data. Is this expected? or the file is corrupt. – Jean-François Fabre Feb 24 '17 at 19:09
  • Well, the error already tells you everything you need to know: that file is an invalid csv file. Either change the file to not-contain null bytes, or use a different/your own parser to parse it. – Bakuriu Feb 24 '17 at 19:11
  • Thanks Jean! Turns out it was corrupt. – ALUW Feb 24 '17 at 19:17
  • 1
    Possible duplicate of [Python CSV error: line contains NULL byte](http://stackoverflow.com/questions/4166070/python-csv-error-line-contains-null-byte) – Nameless One Mar 22 '17 at 14:14

0 Answers0