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

**URL:** <https://forum.inductiveautomation.com/t/solved-topydataset-1st-arg-cant-be-coerced-to-dataset/78581>\
**Category:** Ignition\
**Tags:** perspective, scripting\
**Created:** [August 30, 2023, 8:16pm UTC](https://forum.inductiveautomation.com/t/solved-topydataset-1st-arg-cant-be-coerced-to-dataset/78581 "2023-08-30T20:16:10Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Matthew\_Csengeto](https://avatars.discourse-cdn.com/v4/letter/m/9d8465/32.png) [@Matthew\_Csengeto](https://forum.inductiveautomation.com/u/Matthew_Csengeto)\
**Post date:** [August 30, 2023, 8:16pm UTC](https://forum.inductiveautomation.com/t/solved-topydataset-1st-arg-cant-be-coerced-to-dataset/78581/1 "2023-08-30T20:16:10Z")

</div>

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.

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

```

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [August 30, 2023, 8:18pm UTC](https://forum.inductiveautomation.com/t/solved-topydataset-1st-arg-cant-be-coerced-to-dataset/78581/2 "2023-08-30T20:18:04Z")

</div>

You need the value property.

```auto
ds = system.tag.readBlocking(ReadTagPath)[0].value

```

---

<div class="post-metadata">

**Author:** ![bmeyers](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bmeyers/32/37453_2.png) [@bmeyers](https://forum.inductiveautomation.com/u/bmeyers)\
**Post date:** [August 30, 2023, 8:22pm UTC](https://forum.inductiveautomation.com/t/solved-topydataset-1st-arg-cant-be-coerced-to-dataset/78581/3 "2023-08-30T20:22:34Z")

</div>

> [@Matthew\_Csengeto](#):
>
> `readBlocking`

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

[https://docs.inductiveautomation.com/display/DOC81/system.tag.readBlocking](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.

---

<div class="post-metadata">

**Author:** ![Felipe\_CRM](https://avatars.discourse-cdn.com/v4/letter/f/dfb087/32.png) [@Felipe\_CRM](https://forum.inductiveautomation.com/u/Felipe_CRM)\
**Post date:** [August 30, 2023, 8:23pm UTC](https://forum.inductiveautomation.com/t/solved-topydataset-1st-arg-cant-be-coerced-to-dataset/78581/4 "2023-08-30T20:23:01Z")

</div>

> [@Matthew\_Csengeto](#):
>
> 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]**"

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

---

<div class="post-metadata">

**Author:** ![Matthew\_Csengeto](https://avatars.discourse-cdn.com/v4/letter/m/9d8465/32.png) [@Matthew\_Csengeto](https://forum.inductiveautomation.com/u/Matthew_Csengeto)\
**Post date:** [August 30, 2023, 8:31pm UTC](https://forum.inductiveautomation.com/t/solved-topydataset-1st-arg-cant-be-coerced-to-dataset/78581/5 "2023-08-30T20:31:26Z")

</div>

Thanks!! That was it.

---

<div class="post-metadata">

**Author:** ![Matthew\_Csengeto](https://avatars.discourse-cdn.com/v4/letter/m/9d8465/32.png) [@Matthew\_Csengeto](https://forum.inductiveautomation.com/u/Matthew_Csengeto)\
**Post date:** [August 30, 2023, 8:31pm UTC](https://forum.inductiveautomation.com/t/solved-topydataset-1st-arg-cant-be-coerced-to-dataset/78581/6 "2023-08-30T20:31:57Z")

</div>

You're exactly right.

---

<div class="post-metadata">

**Author:** ![Matthew\_Csengeto](https://avatars.discourse-cdn.com/v4/letter/m/9d8465/32.png) [@Matthew\_Csengeto](https://forum.inductiveautomation.com/u/Matthew_Csengeto)\
**Post date:** [August 30, 2023, 8:36pm UTC](https://forum.inductiveautomation.com/t/solved-topydataset-1st-arg-cant-be-coerced-to-dataset/78581/7 "2023-08-30T20:36:15Z")

</div>

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.
