# Reading tags and creating a table - VISION

**URL:** <https://forum.inductiveautomation.com/t/reading-tags-and-creating-a-table-vision/57421>\
**Category:** Ignition\
**Tags:** database, vision, scripting, ignition81\
**Created:** [March 21, 2022, 4:02pm UTC](https://forum.inductiveautomation.com/t/reading-tags-and-creating-a-table-vision/57421 "2022-03-21T16:02:15Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Esme\_Lopez](https://avatars.discourse-cdn.com/v4/letter/e/ecb155/32.png) [@Esme\_Lopez](https://forum.inductiveautomation.com/u/Esme_Lopez)\
**Post date:** [March 21, 2022, 4:02pm UTC](https://forum.inductiveautomation.com/t/reading-tags-and-creating-a-table-vision/57421/1 "2022-03-21T16:02:16Z")

</div>

Hello everyone, I am reading tags and these tags are visible in a label but I want to save every data in a table to see the all numbers that I am receiving in my label or saving everything in an auxiliar String and then print the list, can anyone help me whit this?.  
Thank you so much.

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [March 21, 2022, 4:03pm UTC](https://forum.inductiveautomation.com/t/reading-tags-and-creating-a-table-vision/57421/2 "2022-03-21T16:03:21Z")

</div>

Do you want to keep the labels, or only have the table ?

---

<div class="post-metadata">

**Author:** ![Esme\_Lopez](https://avatars.discourse-cdn.com/v4/letter/e/ecb155/32.png) [@Esme\_Lopez](https://forum.inductiveautomation.com/u/Esme_Lopez)\
**Post date:** [March 21, 2022, 4:04pm UTC](https://forum.inductiveautomation.com/t/reading-tags-and-creating-a-table-vision/57421/3 "2022-03-21T16:04:24Z")

</div>

In the table will be better

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [March 21, 2022, 4:14pm UTC](https://forum.inductiveautomation.com/t/reading-tags-and-creating-a-table-vision/57421/4 "2022-03-21T16:14:25Z")

</div>

Something like that ?

```python
return [{'tag': path.split('/')[-1],'value': tag.value} for path, tag in zip(paths, system.tag.readBlocking(paths))]

```

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

---

<div class="post-metadata">

**Author:** ![Esme\_Lopez](https://avatars.discourse-cdn.com/v4/letter/e/ecb155/32.png) [@Esme\_Lopez](https://forum.inductiveautomation.com/u/Esme_Lopez)\
**Post date:** [March 21, 2022, 4:16pm UTC](https://forum.inductiveautomation.com/t/reading-tags-and-creating-a-table-vision/57421/5 "2022-03-21T16:16:07Z")

</div>

How can I add a binding?, in the properties table says NO BIDING

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [March 21, 2022, 4:18pm UTC](https://forum.inductiveautomation.com/t/reading-tags-and-creating-a-table-vision/57421/6 "2022-03-21T16:18:14Z")

</div>

You may want to watch the tutorial and read the doc…  
[https://docs.inductiveautomation.com/display/DOC80/Bindings+in+Perspective](https://docs.inductiveautomation.com/display/DOC80/Bindings+in+Perspective)

---

<div class="post-metadata">

**Author:** ![Esme\_Lopez](https://avatars.discourse-cdn.com/v4/letter/e/ecb155/32.png) [@Esme\_Lopez](https://forum.inductiveautomation.com/u/Esme_Lopez)\
**Post date:** [March 21, 2022, 4:20pm UTC](https://forum.inductiveautomation.com/t/reading-tags-and-creating-a-table-vision/57421/7 "2022-03-21T16:20:24Z")

</div>

But I am working with VISION, it is the same?

---

<div class="post-metadata">

**Author:** ![Esme\_Lopez](https://avatars.discourse-cdn.com/v4/letter/e/ecb155/32.png) [@Esme\_Lopez](https://forum.inductiveautomation.com/u/Esme_Lopez)\
**Post date:** [March 21, 2022, 4:24pm UTC](https://forum.inductiveautomation.com/t/reading-tags-and-creating-a-table-vision/57421/8 "2022-03-21T16:24:58Z")

</div>

And how will be in labels?

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [March 21, 2022, 4:36pm UTC](https://forum.inductiveautomation.com/t/reading-tags-and-creating-a-table-vision/57421/9 "2022-03-21T16:36:09Z")

</div>

Oh I’m sorry, I keep messing up my forum filters… I don’t know anything about vision.

---

<div class="post-metadata">

**Author:** ![Esme\_Lopez](https://avatars.discourse-cdn.com/v4/letter/e/ecb155/32.png) [@Esme\_Lopez](https://forum.inductiveautomation.com/u/Esme_Lopez)\
**Post date:** [March 21, 2022, 4:39pm UTC](https://forum.inductiveautomation.com/t/reading-tags-and-creating-a-table-vision/57421/10 "2022-03-21T16:39:08Z")

</div>

Don’t worry and thank you so much

---

<div class="post-metadata">

**Author:** ![kelliott](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kelliott/32/32947_2.png) [@kelliott](https://forum.inductiveautomation.com/u/kelliott)\
**Post date:** [March 21, 2022, 5:10pm UTC](https://forum.inductiveautomation.com/t/reading-tags-and-creating-a-table-vision/57421/11 "2022-03-21T17:10:32Z")

</div>

You could certainly replicate the given solution in Vision. Since script transforms are Perspective exclusive, to do that I would probably utilize the [runScript](https://docs.inductiveautomation.com/display/DOC81/runScript) expression function and the [Script Library](https://docs.inductiveautomation.com/display/DOC81/Project+Library).

Here is my simple example:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/6/d6c29c6da76858b363dcc4faa7668d36fb51a930.png)  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/d/4d5bffa288f5635bb9f77720dfefc3c8a7839196.png)

You would just need to modify the ‘paths’ variable to be your list of tag paths and ‘headers’ to be the headers you want the table to display.

---

<div class="post-metadata">

**Author:** ![Esme\_Lopez](https://avatars.discourse-cdn.com/v4/letter/e/ecb155/32.png) [@Esme\_Lopez](https://forum.inductiveautomation.com/u/Esme_Lopez)\
**Post date:** [March 21, 2022, 6:04pm UTC](https://forum.inductiveautomation.com/t/reading-tags-and-creating-a-table-vision/57421/12 "2022-03-21T18:04:27Z")

</div>

But how I put the tag or how I can reference the tag to the table?

---

<div class="post-metadata">

**Author:** ![andrews](https://avatars.discourse-cdn.com/v4/letter/a/898d66/32.png) [@andrews](https://forum.inductiveautomation.com/u/andrews)\
**Post date:** [March 21, 2022, 6:12pm UTC](https://forum.inductiveautomation.com/t/reading-tags-and-creating-a-table-vision/57421/13 "2022-03-21T18:12:30Z")

</div>

You create a dataset, then pass that dataset into a table component.

Or you could even turn on history for tags and put them into a chart.

What kind tags are are you using? (i.e. stings, ints etc…)

are you logging just for visual, reporting, etc…?

---

<div class="post-metadata">

**Author:** ![Esme\_Lopez](https://avatars.discourse-cdn.com/v4/letter/e/ecb155/32.png) [@Esme\_Lopez](https://forum.inductiveautomation.com/u/Esme_Lopez)\
**Post date:** [March 21, 2022, 6:18pm UTC](https://forum.inductiveautomation.com/t/reading-tags-and-creating-a-table-vision/57421/14 "2022-03-21T18:18:56Z")

</div>

I just want to save the numbers into a table, the tag is OPC

---

<div class="post-metadata">

**Author:** ![Troy](https://avatars.discourse-cdn.com/v4/letter/t/85f322/32.png) [@Troy](https://forum.inductiveautomation.com/u/Troy)\
**Post date:** [March 21, 2022, 6:49pm UTC](https://forum.inductiveautomation.com/t/reading-tags-and-creating-a-table-vision/57421/15 "2022-03-21T18:49:55Z")

</div>

If you want to save the values of a tag to a _database_ table, use the tag historian.

An easy way to display the saved values is with the table component using the tag history binding.

---

<div class="post-metadata">

**Author:** ![andrews](https://avatars.discourse-cdn.com/v4/letter/a/898d66/32.png) [@andrews](https://forum.inductiveautomation.com/u/andrews)\
**Post date:** [March 21, 2022, 6:52pm UTC](https://forum.inductiveautomation.com/t/reading-tags-and-creating-a-table-vision/57421/16 "2022-03-21T18:52:33Z")

</div>

You can just enable history on those tags, and use a table, then filter that table to only show those tags.

Do you want to record to the time “infinitely” or just last 30 minutes etc…?

---

<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:** [March 21, 2022, 7:06pm UTC](https://forum.inductiveautomation.com/t/reading-tags-and-creating-a-table-vision/57421/17 "2022-03-21T19:06:51Z")

</div>

You have to remember that a _Table Component_ is not the same thing as a _Table Structure_ in a database. One can exist without the other.

However, @kelliot did answer your question as you asked it.

How do you read a tag?  
`system.tag.readBlocking()`

How do you put those values into the table?  
`system.dataset.toDataSet()`

The script and expression do exactly what you asked, they read a tag or group of tags value/s, create a dataset, and set the tables Data property equal to that dataset.

@Troy and @andrews have answered the question that we believe you are actually trying to ask.

How do I save the values of a tag/group of tags over time and then display them in a table component?  
That is done by either using the Tag Historian, Transaction Groups, or if your trying to make it real difficult an insert query.

---

<div class="post-metadata">

**Author:** ![Esme\_Lopez](https://avatars.discourse-cdn.com/v4/letter/e/ecb155/32.png) [@Esme\_Lopez](https://forum.inductiveautomation.com/u/Esme_Lopez)\
**Post date:** [March 21, 2022, 9:19pm UTC](https://forum.inductiveautomation.com/t/reading-tags-and-creating-a-table-vision/57421/20 "2022-03-21T21:19:11Z")

</div>

I found why did not work but there is an error : error executing expression binding on projectTags.root Container.Table.data

And now says:  
File: , line 5 , in buildTable  
IndexError: Row 0 doesn’t have the same number of columns as header list

The code that I have is:

```auto

def buildTable():
paths = ['[default]id', ['[default]tag']
headers = ['id','tag']
values = [val.value for val in system.tag.readBlocking(paths)]
return system.dataset.toDataSet(headers,[values])

```

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [March 22, 2022, 8:38am UTC](https://forum.inductiveautomation.com/t/reading-tags-and-creating-a-table-vision/57421/21 "2022-03-22T08:38:19Z")

</div>

Nevermind, I got things all wrong

---

<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:** [March 22, 2022, 10:39am UTC](https://forum.inductiveautomation.com/t/reading-tags-and-creating-a-table-vision/57421/22 "2022-03-22T10:39:18Z")

</div>

> [@pascal.fragnoud](#):
>
> Probably not what you want to do

I agree it’s probably not exactly what they want, but `toDataSet()` needs a list of lists. Each list must have the same number of values as `headers`.

I don’t think either example you provided actually does that.

@Esme_Lopez  
How are `‘id’` and `‘tag’` related?

[Next page](https://forum.inductiveautomation.com/t/reading-tags-and-creating-a-table-vision/57421.md?page=2)
