# csv.Error: line contains NULL byte

**URL:** <https://forum.inductiveautomation.com/t/csv-error-line-contains-null-byte/43044>\
**Category:** Ignition\
**Created:** [February 4, 2021, 11:12pm UTC](https://forum.inductiveautomation.com/t/csv-error-line-contains-null-byte/43044 "2021-02-04T23:12:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![andrews](https://avatars.discourse-cdn.com/v4/letter/a/898d66/32.png) [@andrews](https://forum.inductiveautomation.com/u/andrews)\
**Post date:** [February 4, 2021, 11:12pm UTC](https://forum.inductiveautomation.com/t/csv-error-line-contains-null-byte/43044/1 "2021-02-04T23:12:25Z")

</div>

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:
	pyData.append(row)
	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

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [February 4, 2021, 11:19pm UTC](https://forum.inductiveautomation.com/t/csv-error-line-contains-null-byte/43044/2 "2021-02-04T23:19:15Z")

</div>

Can you share the file?

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

---

<div class="post-metadata">

**Author:** ![andrews](https://avatars.discourse-cdn.com/v4/letter/a/898d66/32.png) [@andrews](https://forum.inductiveautomation.com/u/andrews)\
**Post date:** [February 10, 2021, 8:20pm UTC](https://forum.inductiveautomation.com/t/csv-error-line-contains-null-byte/43044/3 "2021-02-10T20:20:29Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![chasondeshotel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/chasondeshotel/32/20032_2.png) [@chasondeshotel](https://forum.inductiveautomation.com/u/chasondeshotel)\
**Post date:** [February 10, 2021, 9:09pm UTC](https://forum.inductiveautomation.com/t/csv-error-line-contains-null-byte/43044/4 "2021-02-10T21:09:17Z")

</div>

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

> <https://stackoverflow.com/questions/7894856/line-contains-null-byte-in-csv-reader-python>
