Good Morning. I have a question and I believe it is very simple for you.
I have two tables, where the first table reports hourly values
of the efficiency of one machine, and the second table gives the hour by hour of the efficiency of another machine. The idea is to create a new dataset where column 0 will be the values referring to column ‘Hour’, column 1 will refer to the efficiency of the
‘BM1’ and column 2 will refer to ‘BM2’.
exactly. the lines always match, the values of each machine (BM1, BM2) come from SEPASOFT’s MES Analysis Controller components. So every hour I will have a new row and each machine’s table is updated. The idea is to create a script in Event Handlers → PropertyChange, as I will want to update the new table every minute. The MES analysis controller component will provide me with hourly outfeed values, but I have already created a script to create in a custom property of each MES Analysis controller, a dataset that gives me hourly values of the efficiency of each machine
pyTable2Data = system.dataset.toPyDataSet(event.souce.parent.getComponent('path to table 2').data)
#get column data from table two
bm2Data = [row['BM2'] for row in pyTable2Data]
table1Data = event.source.parent.getComponent('path to table 1').data
combinedDataset = system.dataset.addColumn(table1Data,col=bm2Data,colName = pyTable2Data.getColumnName(1),colType=pyTable2Data.getColumnType(1))
you can use bm2 = table2.getColumnAsList(1) to get the column instead of converting to a pyDataSet then constructing the list. You need to know the index of the column, but, well…
It isn't in the Dataset interface, but it happens to be implemented on the BasicDataset, which is the most common implementation. (And on on most others.) In a pinch, passing a generic dataset to the BasicDataset construct to ensure that method is available is pretty cheap.