# List to dataset

**URL:** <https://forum.inductiveautomation.com/t/list-to-dataset/9801>\
**Category:** Ignition\
**Created:** [March 13, 2015, 6:37pm UTC](https://forum.inductiveautomation.com/t/list-to-dataset/9801 "2015-03-13T18:37:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![AJBerera](https://avatars.discourse-cdn.com/v4/letter/a/9fc29f/32.png) [@AJBerera](https://forum.inductiveautomation.com/u/AJBerera)\
**Post date:** [March 13, 2015, 6:37pm UTC](https://forum.inductiveautomation.com/t/list-to-dataset/9801/1 "2015-03-13T18:37:54Z")

</div>

I found this topic elsewhere in Ignition problems but the topic was locked.  
Since I’m looking for the same result, I’ll repost this issue.

[code]dataTable = event.source.parent.getComponent(‘Table’).data  
pyDataIn = system.dataset.toPyDataSet(dataTable)

headers = [“Shift Name”]  
data = []

for row in pyDataIn:  
shiftName = row[“Shiftname”]  
selected = row[“Select”]  
if selected:  
data.append([shiftName])

This error only appears in preview mode in the designer.  
if len(data):  
newDs = system.dataset.toDataSet(headers, data)  
event.source.parent.getComponent(‘Table’).Select = newDs[/code]

This is supposed to take a dataset from a table component and loop through the rows checking to see which rows have the selected value True and then create another dataset of the number of “selected” rows.

The code seems to work, BUT I am getting an error anyways about this

Traceback (most recent call last):

File “event:propertyChange”, line 4, in

TypeError: toPyDataSet(): 1st arg can’t be coerced to com.inductiveautomation.ignition.common.Dataset

Ignition v7.6.6 (b2014040112)  
Java: Sun Microsystems Inc. 1.6.0\_45

---

<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:** [March 13, 2015, 7:08pm UTC](https://forum.inductiveautomation.com/t/list-to-dataset/9801/2 "2015-03-13T19:08:55Z")

</div>

Show the full traceback – it should identify what the dataTable was at that point. Are you sure it wasn’t null?

---

<div class="post-metadata">

**Author:** ![AJBerera](https://avatars.discourse-cdn.com/v4/letter/a/9fc29f/32.png) [@AJBerera](https://forum.inductiveautomation.com/u/AJBerera)\
**Post date:** [March 13, 2015, 8:09pm UTC](https://forum.inductiveautomation.com/t/list-to-dataset/9801/3 "2015-03-13T20:09:00Z")

</div>

I think I found the issue (was unrelated)  
the code works fine.
