csv.Error: line contains NULL byte

When trying to import a csv and put it in a table I get this error.

Traceback (most recent call last):

File “event:actionPerformed”, line 62, in

_csv.Error: line contains NULL byte

my relevant code is

#Master Import
file = open(“locationoffile\ITEM_MASTER2.csv”)
csvData = csv.reader(file)

header = csvData.next()
pyData = []
for row in csvData:
	finalData = system.dataset.toDataSet(header,pyData)
	event.source.parent.getComponent('Master Table').data = finalData

Ignition v7.8.5 (b2016120813)
Java: Oracle Corporation 1.8.0_271

thank you any help would be appreciated. 5 other files work fine

Can you share the file?

The error message seems descriptive enough… suggesting there’s a null byte on one of the lines your file.

I can not share it but now I get
Row 0 doesn’t have the same number of columns as header list. error
after adjusting it a little bit.

I just want to grab information from a CSV and write specific information to certain tags. Maybe there is a easier way to do this.

It’s either an encoding issue or a malformed CSV. I would set the encoding when reading the file (good practice anyway) and have Python tell me what line number of the CSV it’s breaking on and look at it in a text editor

1 Like