Hey,
So I’m still trying to improve my knowledge on how ignition datasets work. What i’m practicing with now is taking one table and distributing it into 5 different tables through a series of conditional statements.
the goal of the code is when I press a button the code,
- reads data from Sampler column.
- compares row value in column 6 to conditional values.
- appends entire row to respective data table.
- changes to the new window
sourceTable = event.source.parent.getComponent('Table')
dataOut = sourceTable.data
pythonDataset = system.dataset.toPyDataSet(dataOut)
header = ["col1", "col2", "col3", "col4", "col5",
"col6", "Sampler", "col7", "col8"]
NewData = []
for row in dataOut:
if row[6]== "Sampler 1":
NewData.append(row)
SamData = system.dataset.toDataSet(header, NewData)
system.gui.getWindow("advance").rootContainer.getComponent("TableT1").data = SamData
elif row[6]== "Sampler 2":
NewData.append(row)
SamData = system.dataset.toDataSet(header, NewData)
system.gui.getWindow("advance").rootContainer.getComponent("TableT2").data = SamData
elif row[6]== "Sampler 3":
NewData.append(row)
SamData = system.dataset.toDataSet(header, NewData)
system.gui.getWindow("advance").rootContainer.getComponent("TableT3").data = SamData
elif row[6]== "Sampler 4":
NewData.append(row)
SamData = system.dataset.toDataSet(header, NewData)
system.gui.getWindow("advance").rootContainer.getComponent("TableT4").data = SamData
elif row[6]== "Sampler 5":
NewData.append(row)
SamData = system.dataset.toDataSet(header, NewData)
system.gui.getWindow("advance").rootContainer.getComponent("TableT5").data = SamData
window = system.nav.openWindow('advance')
system.nav.centerWindow(window)
system.nav.closeParentWindow(event)
This is the Error I get from the Code:
Traceback (most recent call last):
File “event:actionPerformed”, line 15, in
TypeError: ‘com.inductiveautomation.ignition.common.BasicDataset’ object is not iterable