# Dataset not populating table

**URL:** <https://forum.inductiveautomation.com/t/dataset-not-populating-table/43320>\
**Category:** Ignition\
**Created:** [February 11, 2021, 6:20pm UTC](https://forum.inductiveautomation.com/t/dataset-not-populating-table/43320 "2021-02-11T18:20:00Z")\
**Posts on this page:** 20\
**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 11, 2021, 6:20pm UTC](https://forum.inductiveautomation.com/t/dataset-not-populating-table/43320/1 "2021-02-11T18:20:00Z")

</div>

Hello, I used code which works for 4 other files/tables. I created a table. And i created the dataset. But for some odd reason my table remains empty.

import csv

#Monday Import  
file = open("\\location\company Data\Monday\_Data.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(‘Monday Table’).data = finalData

---

<div class="post-metadata">

**Author:** ![bpreston](https://avatars.discourse-cdn.com/v4/letter/b/4af34b/32.png) [@bpreston](https://forum.inductiveautomation.com/u/bpreston)\
**Post date:** [February 11, 2021, 6:24pm UTC](https://forum.inductiveautomation.com/t/dataset-not-populating-table/43320/2 "2021-02-11T18:24:27Z")

</div>

Two things, you need to put your code in a preformatted text section you enclose your code in 3 `'s before and after the code so it will maintain formatting. There is also a button that looks like \</\> that would create the space. The other thing, if it isn’t working, is it giving any error in your console? If so showing that error will help point to the issue.

---

<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 11, 2021, 7:04pm UTC](https://forum.inductiveautomation.com/t/dataset-not-populating-table/43320/3 "2021-02-11T19:04:02Z")

</div>

I get a blank error i cant even open but see down at the bottom of the screen.

That code worked for another file. So i just replicated it. But someone else did originally do it, so I’m tryin to clean it up.

this code is in the script editor for a button.

i don’t know what \</\> button you are talking about.

---

<div class="post-metadata">

**Author:** ![bpreston](https://avatars.discourse-cdn.com/v4/letter/b/4af34b/32.png) [@bpreston](https://forum.inductiveautomation.com/u/bpreston)\
**Post date:** [February 11, 2021, 7:06pm UTC](https://forum.inductiveautomation.com/t/dataset-not-populating-table/43320/4 "2021-02-11T19:06:02Z")

</div>

Are you testing it in the designer or in the project? If you test it in the designer you can open the console and errors will post to it.

And for that symbol I’m talking about in the reply window at the top of it:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/2/725d4193c1d8a9e63e6df295665697526afb8233.png)

---

<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 11, 2021, 7:06pm UTC](https://forum.inductiveautomation.com/t/dataset-not-populating-table/43320/5 "2021-02-11T19:06:14Z")

</div>

> [@bpreston](#):
>
> `

also when i put ``` it will not let me close the script editor

---

<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 11, 2021, 7:08pm UTC](https://forum.inductiveautomation.com/t/dataset-not-populating-table/43320/6 "2021-02-11T19:08:13Z")

</div>

I’m testing in designer  
i get this error

```auto
ERROR [ActionAdapter-AWT-EventQueue-2] <HTML>Error executing script for event:&nbsp;<code><b>actionPerformed</b></code><BR>on component:&nbsp;<code><b>Button</b></code>.
Traceback (most recent call last):
  File "<event:actionPerformed>", line 59, in <module>
IOError: (21, 'Is a directory', '')

```

---

<div class="post-metadata">

**Author:** ![bpreston](https://avatars.discourse-cdn.com/v4/letter/b/4af34b/32.png) [@bpreston](https://forum.inductiveautomation.com/u/bpreston)\
**Post date:** [February 11, 2021, 7:09pm UTC](https://forum.inductiveautomation.com/t/dataset-not-populating-table/43320/7 "2021-02-11T19:09:26Z")

</div>

In your button’s action performed script, what do you have on line 59 in the script editor?

---

<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 11, 2021, 7:13pm UTC](https://forum.inductiveautomation.com/t/dataset-not-populating-table/43320/8 "2021-02-11T19:13:30Z")

</div>

this is on that line

```auto
file = open("\\location\company Data\Monday_Data.csv")

```

i made an adjustment for indexing and got this error

```auto
ERROR [ActionAdapter-AWT-EventQueue-2] <HTML>Error executing script for event:&nbsp;<code><b>actionPerformed</b></code><BR>on component:&nbsp;<code><b>Button</b></code>.
Traceback (most recent call last):
  File "<event:actionPerformed>", line 66, in <module>
IndexError: Row 0 doesn't have the same number of columns as header list.

```

---

<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 11, 2021, 7:15pm UTC](https://forum.inductiveautomation.com/t/dataset-not-populating-table/43320/9 "2021-02-11T19:15:50Z")

</div>

I has extended to first line to have as many items as the most filled row and am using `header = csvData.next()` which should take care of that. but something is funky

---

<div class="post-metadata">

**Author:** ![bpreston](https://avatars.discourse-cdn.com/v4/letter/b/4af34b/32.png) [@bpreston](https://forum.inductiveautomation.com/u/bpreston)\
**Post date:** [February 11, 2021, 7:21pm UTC](https://forum.inductiveautomation.com/t/dataset-not-populating-table/43320/10 "2021-02-11T19:21:25Z")

</div>

It doesn’t like the path your using, try adding an extra \ with each.

```auto
file = open("\\location\\company Data\\Monday_Data.csv")

```

To explain it, the \ is an escape character for python. By doubling it up it will treat it as a backslash which is what your looking for. A forward slash may also work as a fix.

---

<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 11, 2021, 9:25pm UTC](https://forum.inductiveautomation.com/t/dataset-not-populating-table/43320/11 "2021-02-11T21:25:15Z")

</div>

The weird part is I use that exact same code for 3 other files. And it places all of them in the table and lets me pull from them. But for some weird reason with this file is not working. i tried a combo of slashes but no luck.  
this is the last error i got

```auto
ERROR [ActionAdapter-AWT-EventQueue-2] <HTML>Error executing script for event:&nbsp;<code><b>actionPerformed</b></code><BR>on component:&nbsp;<code><b>Button</b></code>.
Traceback (most recent call last):
  File "<event:actionPerformed>", line 66, in <module>
IndexError: Row 0 doesn't have the same number of columns as header list.

```

---

<div class="post-metadata">

**Author:** ![bpreston](https://avatars.discourse-cdn.com/v4/letter/b/4af34b/32.png) [@bpreston](https://forum.inductiveautomation.com/u/bpreston)\
**Post date:** [February 11, 2021, 9:28pm UTC](https://forum.inductiveautomation.com/t/dataset-not-populating-table/43320/12 "2021-02-11T21:28:45Z")

</div>

Line 66 is a different error than the original one. I’m assuming it lines up with your system.dataset.toDataSet(). If your headers and your rows under it don’t match it will do that. What I would do is add a print for your header and a print for row in your loop and look at the data returned to make sure it is processing it how you think.

```auto
import csv

#Monday Import
file = open("\\location\\company Data\\Monday_Data.csv")
csvData = csv.reader(file)

header = csvData.next()
print header
pyData = []
for row in csvData:
     pyData.append(row)
     print row
finalData = system.dataset.toDataSet(header,pyData)
event.source.parent.getComponent(‘Monday Table’).data = finalData

```

Also where it lists row 0, I’m wondering do you have an empty row between your header and your data in your CSV. I’d look specifically at that row to start but it has to line up all the way through or it will throw that error. You could also potentially have an empty column that has a header but doesn’t have any data in it at for the last column.

---

<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 11, 2021, 9:40pm UTC](https://forum.inductiveautomation.com/t/dataset-not-populating-table/43320/13 "2021-02-11T21:40:22Z")

</div>

The console made it through row 0 and 1 printing then threw the error. But I did notice know the header did not cover all the columns. so I extended it . but not every row has data in it for that column. Do I need data in every row and column? Could I program a fail safe. if row col null insert NA or something?

---

<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 11, 2021, 9:42pm UTC](https://forum.inductiveautomation.com/t/dataset-not-populating-table/43320/14 "2021-02-11T21:42:07Z")

</div>

I know the other file has blanks in rows for cols, so not sure why this one is being so nit picky

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [February 11, 2021, 9:47pm UTC](https://forum.inductiveautomation.com/t/dataset-not-populating-table/43320/15 "2021-02-11T21:47:10Z")

</div>

Each row of data must have the same number of elements as the list of headers (column names). You can supply a python `None` for null, but you may have flaky behavior if any nulls are in the first row. The toDataSet() function determines column data types from the first row, and will use String by default. If you cannot guarantee a non-null first row, you should use the underlying platform `DatasetBuilder` tool, so you can explicitly set the column data types. There are numerous examples on this forum.

---

<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 11, 2021, 9:52pm UTC](https://forum.inductiveautomation.com/t/dataset-not-populating-table/43320/16 "2021-02-11T21:52:35Z")

</div>

I did find some extended rows further than what I realized. I am gonna to try and extend the header to see if that solves it

---

<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 11, 2021, 10:06pm UTC](https://forum.inductiveautomation.com/t/dataset-not-populating-table/43320/17 "2021-02-11T22:06:44Z")

</div>

i still get

```auto
Traceback (most recent call last):
  File "<event:actionPerformed>", line 68, in <module>
IndexError: Row 0 doesn't have the same number of columns as header list.

```

code is

```auto
file = open("\\\\location\\datasource$\\location\\Item_Master.csv")
csvData = csv.reader(file)

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

```

 ![errorprint](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/0/70956d8fe4287c83d928c62644e696e209c29259.png)

---

<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 11, 2021, 11:04pm UTC](https://forum.inductiveautomation.com/t/dataset-not-populating-table/43320/18 "2021-02-11T23:04:13Z")

</div>

fixed by having IT clean the .csv file up. Finally got the data in. Still having some issues but I created a separate discussion for that.

thank you

---

<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 11, 2021, 11:35pm UTC](https://forum.inductiveautomation.com/t/dataset-not-populating-table/43320/19 "2021-02-11T23:35:12Z")

</div>

link to new discussion with following issue. any help appreciated

---

<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 11, 2021, 11:36pm UTC](https://forum.inductiveautomation.com/t/dataset-not-populating-table/43320/20 "2021-02-11T23:36:00Z")

</div>

[http://forum.inductiveautomation.com/t/import-button-silently-running-vs-opening-window-not-working-anymore/43334/4](http://forum.inductiveautomation.com/t/import-button-silently-running-vs-opening-window-not-working-anymore/43334/4)
