Best way to read multiple tags and bind them to a table

That worked, thank you!
FYI you have a typo in the second line .fomrat -> .format

1 Like

Something I just noticed and with the code you sent cannot seem to figure out is how to remove the Number 0 row as I do not have a 0 value tag.


In the previous code I used these lines seemed to fix it:

	tagPaths = [parentPath + 'Job {0}/State'.format(tag) for tag in range(1,21)]

	for tag in range(len(values)):
	    data.append(['Job {0}'.format(tag + 1),values[tag].value])

However the new code does not have the for loop and setting the range(1,21) actually removes my Number 20 row. Other than that the data is correct.

The for loop is there, it is just contained in the comprehension.

As for the starting at 0, that's my mistake. I tend to make any "id" type column I have be zero based so that it works better in a script context. You can give the enumerate() function a starting value as well.

data = [[job,state.value] for job,state in enumerate(qValues,1)]
1 Like

Thanks it worked! Nice trick too, I didnt know about that.