[SOLVED] ToPyDataSet() - 1st arg can't be coerced to Dataset

I have two datasets. One of them works with the toPyDataSet function and the other does not.
'ds2' is contained within a custom property in an object in Perspective.
'ds' is contained in a Memory Tag.

If I use the toPyDataSet function with the custom property dataset, it works fine.
If I use it with the one in the Memory Tag (which I am trying to do in order to move a script to the Gateway rather than as a binding of an object on a page), it gives the error: TypeError: toPyDataSet(): 1st arg can't be coerced to com.inductiveautomation.ignition.common.Dataset.

What is crazy, is that if i simply type "return ds" or "return ds2", the output at the bottom of the window is exactly the same which happens to be "Dataset[124 rows, 2 cols]"

So the program seems to see them as exactly the same thing and yet it is not working.

ds		= system.tag.readBlocking(ReadTagPath)[0]
ds2		= self.custom.msg
pd		= system.dataset.toPyDataSet(ds)

You need the value property.

ds = system.tag.readBlocking(ReadTagPath)[0].value
1 Like

As @lrose mentioned the function readBlocking returns a list of qualified values.

https://docs.inductiveautomation.com/display/DOC81/system.tag.readBlocking

Also I believe Perspective sessions run on the Gateway so moving the function to a memory tag isn't really helping you.

1 Like

At some point, bindings automatically extract the value part of a QualifiedValue which is really convenient but probably doesn't help with the confusion.

2 Likes

Thanks!! That was it.

You're exactly right.

This way the script runs once and the results can be shared for all users, but we were told that when Scripts are proliferated in the Pages, it's more taxing as multiple instances of the same Page may be loaded at once for various monitors/users, so this saves on work for the CPU.