Getting a row from a dataset

I have a dataset with 1 row that I would like to add to another dataset for exporting.

I know I can easily loop though the columns, append them to a list and add that as the new row but is there built in way to just get the entire row?

For example; if I remember correctly, in .NET I could use something like DataSet.Tables[0].Rows[0] to get the entire row. I haven’t found anything similar in the Ignition documentation.

Something like this:

# This code is not valid
datset1 = system.dataset.addRow(dataset1, dataset1.rowCount, dataset2.rows[0])

would be much nicer than this:

newRow = []
for col in range(dataset2.columnCount):
    newRow.append(dataset2.getValueAt(0, col))
datset1 = system.dataset.addRow(dataset1, dataset1.rowCount, newRow)

This is a little better and works:

row = list(system.dataset.toPyDataSet(dataset2)[0])
dataset1 = system.dataset.addRow(dataset1, dataset1.rowCount, row)

[quote=“nmudge”]This is a little better and works:

row = list(system.dataset.toPyDataSet(dataset2)[0]) dataset1 = system.dataset.addRow(dataset1, dataset1.rowCount, row) [/quote]

Nice! So on a python dataset you can reference a row using brackets?

row = myPyDataset[0]

Yes, that is correct.

You can also access values this way too:

print myPyDataset[0]["col name"]

or

print myPyDataset[0][3]