# Dataset table in Ignition 8.0.1 scripting

**URL:** <https://forum.inductiveautomation.com/t/dataset-table-in-ignition-8-0-1-scripting/25220>\
**Category:** Ignition Early Access\
**Created:** [May 22, 2019, 10:02am UTC](https://forum.inductiveautomation.com/t/dataset-table-in-ignition-8-0-1-scripting/25220 "2019-05-22T10:02:32Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![schmandy90](https://avatars.discourse-cdn.com/v4/letter/s/ad7895/32.png) [@schmandy90](https://forum.inductiveautomation.com/u/schmandy90)\
**Post date:** [May 22, 2019, 10:02am UTC](https://forum.inductiveautomation.com/t/dataset-table-in-ignition-8-0-1-scripting/25220/1 "2019-05-22T10:02:32Z")

</div>

Hi,

this method I’ve made in Ignition 8.0 perspective.

I’m trying to find a specific value “id” in a column. For each row that has a matching value in the specified column “Col 1” I want to make a new dataset of these rows.

This is the structure of the data when I write it to a label:

 ![Annotation%202019-05-22%20115934](https://us1.discourse-cdn.com/inductiveautomation/original/2X/7/77b01f076f9a51d32f10f436977b8774beae5bb6.png)

The structure of the header when I write it to a label:

 ![Annotation%202019-05-22%20120105](https://us1.discourse-cdn.com/inductiveautomation/original/2X/2/2bafb9e48b6cd676db8aee83d37fe18eef3d1849.png)

I’m getting an error message of:

com.inductiveautomation.ignition.common.script.JythonExecException: Traceback (most recent call last): File “”, line 5, in runAction File “”, line 19, in findNotes IndexError: Row 0 doesn’t have the same number of columns as header list.

I can’t see that they should be of different sizes… Any help?

```auto
def findNotes(self, id):
	"""
	Custom method that can be invoked directly on this component.

	Arguments:
		self: Reference to this component
		id: Value to find in column of table
	"""
	tbl = self.getSibling('Table').props.data
	newData = []

	col = "Col 1"
	colNames = list(tbl.getColumnNames())
	
	for row in system.dataset.toPyDataSet(tbl):
		rowList = []
		value = row[col]
		if value == id:
			rowList.append(list(row))
			newData.append(rowList)
	
	ds = system.dataset.toDataSet(colNames,newData)
	return ds

```

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [May 22, 2019, 2:43pm UTC](https://forum.inductiveautomation.com/t/dataset-table-in-ignition-8-0-1-scripting/25220/2 "2019-05-22T14:43:45Z")

</div>

I can’t be positive - because I don’t know how the bindings were applied to the Labels in the screenshots you posted - but I see that the first screenshot has length of 1, while the second has length 11. In the first screenshot, you have 11 values inside a list of length 1, which is in another list of length 1 - so any length comparisons would return the length of the outer-most object, which is a list of length 1.

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [May 22, 2019, 2:48pm UTC](https://forum.inductiveautomation.com/t/dataset-table-in-ignition-8-0-1-scripting/25220/3 "2019-05-22T14:48:47Z")

</div>

> [@schmandy90](#):
>
> ```auto
> if value == id: 
> rowList.append(list(row)) 
> newData.append(rowList)
> 
> ```

This looks to be the cuplrit.

- `row` is a list
- then you benignly wrap it in a list (end result is no change)
- then you append this list to a list. (`rowList`)
- then you append that list of a list to another list (`newData`)

---

<div class="post-metadata">

**Author:** ![schmandy90](https://avatars.discourse-cdn.com/v4/letter/s/ad7895/32.png) [@schmandy90](https://forum.inductiveautomation.com/u/schmandy90)\
**Post date:** [May 23, 2019, 9:00am UTC](https://forum.inductiveautomation.com/t/dataset-table-in-ignition-8-0-1-scripting/25220/4 "2019-05-23T09:00:02Z")

</div>

Yes, correctly I had appended this once too much.

I found one more mistake, I declare the `rowList = []` inside the for loop, nesting it further. So once I moved this outside the loop, it works!

Thank you.

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [May 23, 2019, 2:07pm UTC](https://forum.inductiveautomation.com/t/dataset-table-in-ignition-8-0-1-scripting/25220/5 "2019-05-23T14:07:06Z")

</div>

Just for clarity for other users, could you post the corrected code?

---

<div class="post-metadata">

**Author:** ![schmandy90](https://avatars.discourse-cdn.com/v4/letter/s/ad7895/32.png) [@schmandy90](https://forum.inductiveautomation.com/u/schmandy90)\
**Post date:** [May 23, 2019, 2:09pm UTC](https://forum.inductiveautomation.com/t/dataset-table-in-ignition-8-0-1-scripting/25220/6 "2019-05-23T14:09:27Z")

</div>

```auto
def findNotes(self, id):
	"""
	Custom method that can be invoked directly on this component.

	Arguments:
		self: Reference to this component
		id: 
	"""
	
	tbl = self.getSibling('Table').props.notesData
	col = "Col 1"
	colNames = list(tbl.getColumnNames())
	rowList = []
	
	for row in system.dataset.toPyDataSet(tbl):
		value = row[col]
		if value == id:
			rowList.append(list(row))
	
	ds = system.dataset.toDataSet(colNames,rowList)
	return ds

```
