Can I use system.tag.read for a dataset

Example:

ValveDataset = system.tag.read("System1/Project1/HOA/Valves")
    for rowRead in ValveDataset:
        CRvalveTo[rowRead['id']] = rowRead['description']

or do datasets need to be read differently.

system.tag.read() returns a Qualified Value, so you need to reference the value attribute.

ValveDataset = system.tag.read("System1/Project1/HOA/Valves").value
for rowRead in ValveDataset:
    CRvalveTo[rowRead['id']] = rowRead['description']

For anyone who comes by in the future, on V8.0 or later:

You should use system.tag.readBlocking. system.tag.read is depreciated.

readBlocking returns a list of Qualified Values, so it’ll look like:
ValveDataset = system.tag.readBlocking([tagPath])[0].value

I don’t know what type of dataset the readBlocking will return, a regular dataset or a pydataset. The regular dataset isn’t iterable (I don’t think), so you’ll need to convert a regular dataset if readBlocking doesn’t return a pydataset by default. You can convert using:

pydata = system.dataset.toPyDataset(ValveDataset)

Then you can iterate over pydata as above.

Their system is Ignition 7.8, so system.tag.read() is correct.

How did you figure this out? I don’t see a version tag.

@lrose is familiar with my sobbing on here. lol @zacht

Heh. (Spelling) Deprecated just means it isn’t documented for new users. IA is unlikely to actually break these any time soon.

TIL. I didn’t know there was a defined difference.

It is a standard dataset. I failed to correct that part of the code.

This:

ValveDataset = system.tag.read("System1/Project1/HOA/Valves").value
for rowRead in range(ValveDataset.rowCount):
    CRvalveTo[ValveDataset.getValueAt(rowRead,'id')] = ValveDataset.getValueAt(rowRead,'description')

or

ValveDataset = system.dataset.toPyDataset(system.tag.read("System1/Project1/HOA/Valves").value)
for rowRead in ValveDataset:
    CRvalveTo[rowRead['id']] = rowRead['description']