# How to create Dataset from tags?

**URL:** <https://forum.inductiveautomation.com/t/how-to-create-dataset-from-tags/84243>\
**Category:** Maker\
**Tags:** perspective\
**Created:** [January 13, 2024, 6:03pm UTC](https://forum.inductiveautomation.com/t/how-to-create-dataset-from-tags/84243 "2024-01-13T18:03:35Z")\
**Posts on this page:** 18\
**Page:** 2

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [January 20, 2024, 6:34pm UTC](https://forum.inductiveautomation.com/t/how-to-create-dataset-from-tags/84243/22 "2024-01-20T18:34:59Z")

</div>

Yes, but your change in the `def` line broke it. The comment in the sample code for `tagFolder` indicates what the **caller** should supply.

---

<div class="post-metadata">

**Author:** ![Vidar\_Hetlelid](https://avatars.discourse-cdn.com/v4/letter/v/dfb087/32.png) [@Vidar\_Hetlelid](https://forum.inductiveautomation.com/u/Vidar_Hetlelid)\
**Post date:** [January 20, 2024, 6:39pm UTC](https://forum.inductiveautomation.com/t/how-to-create-dataset-from-tags/84243/23 "2024-01-20T18:39:51Z")

</div>

> [@pturmel](#):
>
> `def`

Uhm, not sure what you mean. Should i not have the tagfolder in this line?  
def getDatasetFromArrayTags([default]Brewfather\_OPCUA):

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [January 20, 2024, 6:40pm UTC](https://forum.inductiveautomation.com/t/how-to-create-dataset-from-tags/84243/24 "2024-01-20T18:40:44Z")

</div>

No. That comes from the caller.

{ Seems to me you need to go through some python scripting basics. }

---

<div class="post-metadata">

**Author:** ![Vidar\_Hetlelid](https://avatars.discourse-cdn.com/v4/letter/v/dfb087/32.png) [@Vidar\_Hetlelid](https://forum.inductiveautomation.com/u/Vidar_Hetlelid)\
**Post date:** [January 20, 2024, 6:55pm UTC](https://forum.inductiveautomation.com/t/how-to-create-dataset-from-tags/84243/25 "2024-01-20T18:55:51Z")

</div>

Sure, i'll could use some basic Python scripting...

I think the 1 and 2 arg is right? But I dont get the purpose of the 3.?

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/a/f/af6cc398aef1c482eb2d29ac9cbef658f8168896.png)

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [January 20, 2024, 6:57pm UTC](https://forum.inductiveautomation.com/t/how-to-create-dataset-from-tags/84243/26 "2024-01-20T18:57:07Z")

</div>

Supply the tag folder string.

---

<div class="post-metadata">

**Author:** ![Vidar\_Hetlelid](https://avatars.discourse-cdn.com/v4/letter/v/dfb087/32.png) [@Vidar\_Hetlelid](https://forum.inductiveautomation.com/u/Vidar_Hetlelid)\
**Post date:** [January 20, 2024, 7:07pm UTC](https://forum.inductiveautomation.com/t/how-to-create-dataset-from-tags/84243/27 "2024-01-20T19:07:07Z")

</div>

> [@pturmel](#):
>
> ```auto
> # tagFolder should be something like "[mqttProvider]path/to/recipe/folder"
> def getDatasetFromArrayTags(tagFolder):
> paths = [tagFolder+'/'+c for c in columnTags]
> qvList = system.tag.readBlocking(paths)
> if all(qv.quality.good for qv in qvList):
> columnArrays = [qv.value for qv in qvList]
> return system.tag.toDataSet(columnTags, map(None, *columnArrays))
> # Any bad quality yields no dataset
> return None
> 
> ```

Of course, that makes sence, thanks, but i'll get this error.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/9/89a76a0dbdfd46d61011b25ed7f13f563daf9fe2.png)

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [January 20, 2024, 7:10pm UTC](https://forum.inductiveautomation.com/t/how-to-create-dataset-from-tags/84243/28 "2024-01-20T19:10:34Z")

</div>

You have enclosed your tag folder path in curly braces, which makes the expression attempt to read the path's value. You need to pass a string. If a constant, put it in quotes. If you have the string in a property, put the path to the property in curly braces.

{ Seems to me you need to go through some Ignition expression binding training. }

> [@pturmel](#):
>
> Side note: Have you gone through Inductive University? It is vital for newcomers.

I'll stop here until I hear from you that you've completed IU.

---

<div class="post-metadata">

**Author:** ![Vidar\_Hetlelid](https://avatars.discourse-cdn.com/v4/letter/v/dfb087/32.png) [@Vidar\_Hetlelid](https://forum.inductiveautomation.com/u/Vidar_Hetlelid)\
**Post date:** [January 20, 2024, 7:17pm UTC](https://forum.inductiveautomation.com/t/how-to-create-dataset-from-tags/84243/29 "2024-01-20T19:17:47Z")

</div>

> [@pturmel](#):
>
> h makes the expression attempt to read the path's value. You need to pass a string. If a constant, put it in quotes. If you

I'll tried with quote also, but still error.

I have done some of the IU training, but I will do a lot more for sure.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/1/415c335ea67971122a708cb7a01c7466d2834bb5.png)  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/b/7b3a2733b81086817c2b95df874d797421cac4b2.png)

---

<div class="post-metadata">

**Author:** ![Vidar\_Hetlelid](https://avatars.discourse-cdn.com/v4/letter/v/dfb087/32.png) [@Vidar\_Hetlelid](https://forum.inductiveautomation.com/u/Vidar_Hetlelid)\
**Post date:** [January 20, 2024, 8:05pm UTC](https://forum.inductiveautomation.com/t/how-to-create-dataset-from-tags/84243/30 "2024-01-20T20:05:37Z")

</div>

Is there something wrong with script you made? Do I need to change anything but the columnTags?

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/2/2267fab24065d37a415ce1d198f4522e10bedaed.png)

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [January 20, 2024, 8:06pm UTC](https://forum.inductiveautomation.com/t/how-to-create-dataset-from-tags/84243/31 "2024-01-20T20:06:37Z")

</div>

> [@Vidar\_Hetlelid](#):
>
> something wrong with script

Could be. Call it from the designer script console.

---

<div class="post-metadata">

**Author:** ![Vidar\_Hetlelid](https://avatars.discourse-cdn.com/v4/letter/v/dfb087/32.png) [@Vidar\_Hetlelid](https://forum.inductiveautomation.com/u/Vidar_Hetlelid)\
**Post date:** [January 20, 2024, 8:16pm UTC](https://forum.inductiveautomation.com/t/how-to-create-dataset-from-tags/84243/32 "2024-01-20T20:16:14Z")

</div>

Thanks. How can I pass the tagfolder path to the script console?

And yes, I am reading articles and watching the videos on IU trying to understand this, but I'm really stuck here..

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/2/528c57e10d8be6e94ec98aad417043e26c5d82e7.png)

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [January 20, 2024, 8:24pm UTC](https://forum.inductiveautomation.com/t/how-to-create-dataset-from-tags/84243/33 "2024-01-20T20:24:01Z")

</div>

> [@pturmel](#):
>
> Call it

Don't put the sample code in the script console. _ **Call** _ the function from script console. One line:

```auto
ds = BrewfatherDatasetDropdown.getDatasetFromArrayTags("[default]Brewfather_OPCUA")

```

This will produce a more complete error for you (us) to see.

---

<div class="post-metadata">

**Author:** ![Vidar\_Hetlelid](https://avatars.discourse-cdn.com/v4/letter/v/dfb087/32.png) [@Vidar\_Hetlelid](https://forum.inductiveautomation.com/u/Vidar_Hetlelid)\
**Post date:** [January 20, 2024, 8:26pm UTC](https://forum.inductiveautomation.com/t/how-to-create-dataset-from-tags/84243/34 "2024-01-20T20:26:34Z")

</div>

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/5/858d16610476c0398bcbadc02cf16de082b53e9a.png)

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [January 20, 2024, 8:27pm UTC](https://forum.inductiveautomation.com/t/how-to-create-dataset-from-tags/84243/35 "2024-01-20T20:27:19Z")

</div>

Have you saved the project since you created that script?

{ Please post errors as copy and pasted text, not screenshots. Use the "preformatted text" button in the forum comment editor to keep it neat. }

---

<div class="post-metadata">

**Author:** ![Vidar\_Hetlelid](https://avatars.discourse-cdn.com/v4/letter/v/dfb087/32.png) [@Vidar\_Hetlelid](https://forum.inductiveautomation.com/u/Vidar_Hetlelid)\
**Post date:** [January 20, 2024, 8:28pm UTC](https://forum.inductiveautomation.com/t/how-to-create-dataset-from-tags/84243/36 "2024-01-20T20:28:40Z")

</div>

Yes, but I updated my comment above since I have changed the name of the script from "BrewfatherDatasetDropdown" to "BrewfatherDataset".

This is the correct error:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/f/4f020cfbdfd9a0cc53bb908e2772e3a2bce7ecfe.png)

Traceback (most recent call last):  
File "", line 1, in   
File "module:BrewfatherDataset", line 9, in getDatasetFromArrayTags  
AttributeError: 'com.inductiveautomation.ignition.designer.gui.tool' object has no attribute 'toDataSet'

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [January 20, 2024, 8:29pm UTC](https://forum.inductiveautomation.com/t/how-to-create-dataset-from-tags/84243/37 "2024-01-20T20:29:13Z")

</div>

Replace `system.tag.toDataSet` with `system.dataset.toDataSet`.

{ I'm unavailable for the next few hours. The community might help. }

---

<div class="post-metadata">

**Author:** ![Vidar\_Hetlelid](https://avatars.discourse-cdn.com/v4/letter/v/dfb087/32.png) [@Vidar\_Hetlelid](https://forum.inductiveautomation.com/u/Vidar_Hetlelid)\
**Post date:** [January 20, 2024, 8:31pm UTC](https://forum.inductiveautomation.com/t/how-to-create-dataset-from-tags/84243/38 "2024-01-20T20:31:43Z")

</div>

Thank so much, again! Now its working 🙂

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/8/58e90c115ec7d82e569ae1f9f48358b86290560e.png)

---

<div class="post-metadata">

**Author:** ![Vidar\_Hetlelid](https://avatars.discourse-cdn.com/v4/letter/v/dfb087/32.png) [@Vidar\_Hetlelid](https://forum.inductiveautomation.com/u/Vidar_Hetlelid)\
**Post date:** [January 20, 2024, 8:38pm UTC](https://forum.inductiveautomation.com/t/how-to-create-dataset-from-tags/84243/39 "2024-01-20T20:38:51Z")

</div>

One more thing, is there a simple way to not list the values if value is "-1" or "Ingen"? If not, I can manipulate the strings in PLC, but It would be nice if possible in ignition 🙂

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/c/2c7152ca6e9de0f01f379e856fcc16f9b47cfe21.png)

[Previous page](https://forum.inductiveautomation.com/t/how-to-create-dataset-from-tags/84243.md?page=1)
