Read fields from dataset tag via script

Hello,
I need help to read fields of a dataset tag (for example the component at row 3 and coloumn 7) using function like system.tag.read, to write them into other appropriate single tags.

Many thanks
Claudio

1 Like

To use a dataset tag field value you will have to read and convert to a pydataset.

val = system.dataset.toPyDataSet(system.tag.read('PathToDataSetTag').value)
print val[3][7]
print val[2][7]
print val[1][7]

1 Like

I prefer pyDatasets as well, but remember you can access the data directly in a ‘normal’ dataset:

data = system.tag.read('Dataset tag').value
print data.getValueAt(3, 7)
1 Like

I hardly ever use toPyDataSet(). The getValueAt() method is easy to use in list comprehensions, and it’s basically what happens under the hood if you do convert.

1 Like

I primarily use it when looping over all the elements of a dataset in a for value in values construct - it feels much neater :slight_smile:

1 Like

I have just gotten so used to looping datasets that I prefer the pyDataSet format.
Convert it once and then access or loop.

1 Like

thank you
I have used your suggestion …

thank you all, I have solved using your precious suggestions.
Many thanks
Claudio

11 posts were split to a new topic: PyDataset Performance Questions