I am trying to add a column into a dataset using the system.dataset.addColumn function and I am running into a problem.
I have the following data with me-
tracedata = system.tag.queryTagHistory(tagPaths,startts,stopts,numsec)
tracedata1 = system.dataset.toPyDataSet(tracedata)
tracedata2 = system.dataset.toDataSet(tracedata1)
tracedata, tracedata1 and tracedata2 have 10 rows and 3 columns. For each row, I need to add a new column titled ‘newcol’ and add a fixed number 123456 to the tracedata2 dataset. I use the following code in order to create the pysequence column necessary for use in the system.dataset.addColumn function
value = 123456
valueset = []
for i in range(0,9):
valueset.append([str(value)])
Then I try using the system.dataset.addColumn function as follows:
system.dataset.addColumn(tracedata2,valueset,“newcol”,type(""))
However, I get an error saying TypeError: toDataSet(): 1st arg can’t be coerced to com.inductiveautomation.ignition.common.script.builtin.DatasetUtilities$PyDataSet
Looks like valueset is a list and not a pysequence. How can I make valueset into a pysequence column?
I ran into a different problem now. I am trying to add a column into a dataset using the system.dataset.addColumn function.
I have the following data with me-
tracedata = system.tag.queryTagHistory(tagPaths,startts,stopts,numsec)
tracedata1 = system.dataset.toPyDataSet(tracedata)
tracedata2 = system.dataset.toDataSet(tracedata1)
tracedata, tracedata1 and tracedata2 have 10 rows and 3 columns. For each row, I need to add a new column titled ‘newcol’ and add a fixed number 123456 to the tracedata2 dataset. I use the following code in order to create the pysequence column necessary for use in the system.dataset.addColumn function
value = 123456
valueset = []
for i in range(0,9):
valueset.append([str(value)])
Then I try using the system.dataset.addColumn function as follows:
system.dataset.addColumn(tracedata2,valueset,“newcol”,type(""))
However, I get an error saying TypeError: toDataSet(): 1st arg can’t be coerced to com.inductiveautomation.ignition.common.script.builtin.DatasetUtilities$PyDataSet
Looks like valueset is a list and not a pysequence. How can I make valueset into a pysequence column?
Thank you very much! When I try
tracedata = system.dataset.addColumn(tracedata,valueset,“newcol”,type("")),
I get an error message saying TypeError: toDataSet(): 1st arg can’t be coerced to com.inductiveautomation.ignition.common.script.builtin.DatasetUtilities$PyDataSet
Ignition is considering valueset as a list but is expecting a pysequence column for the system.dataset.addColumn function to work.
The way I am creating valueset is as follows. For each row in tracedata, I need to add a new column titled ‘newcol’ and add a fixed number 123456 to the tracedata dataset.
value = 123456
valueset = []
for i in range(0,9):
valueset.append([str(value)])
How should I define valueset so that it is considered as a pysequence column and not a list?