# Creating array tags

**URL:** <https://forum.inductiveautomation.com/t/creating-array-tags/18554>\
**Category:** Ignition\
**Created:** [June 21, 2018, 12:52pm UTC](https://forum.inductiveautomation.com/t/creating-array-tags/18554 "2018-06-21T12:52:54Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![leversole](https://avatars.discourse-cdn.com/v4/letter/l/db5fbb/32.png) [@leversole](https://forum.inductiveautomation.com/u/leversole)\
**Post date:** [June 21, 2018, 12:52pm UTC](https://forum.inductiveautomation.com/t/creating-array-tags/18554/1 "2018-06-21T12:52:54Z")

</div>

Have searched the help and the forums, cannot find an example of creating an array tag…I am probably overlooking something simple…anyway, I have a control logix array…600 reals…lets call it BottomRaw…  
I create a new OPC tag, select float array as the type…the first issue is that it will not let me select the main “folder” for the tag, if I type in the root name (folder name) it doesnt work, and I have tried various ways with the name and empty brackets…BottomRay, BottomRaw[0], etc

![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/3/31ef59b71a69e5ae29e37de2d84b01b74f79822e.jpg)

---

<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:** [June 21, 2018, 12:55pm UTC](https://forum.inductiveautomation.com/t/creating-array-tags/18554/2 "2018-06-21T12:55:46Z")

</div>

That’s because Ignition doesn’t support actual arrays of primitive types. Due to an unfortunate and non-intuitive naming decision, the feature that exposes the individual bits of primitive types is _ **called** _ an array of that primitive. One primitive element at a time.

---

<div class="post-metadata">

**Author:** ![leversole](https://avatars.discourse-cdn.com/v4/letter/l/db5fbb/32.png) [@leversole](https://forum.inductiveautomation.com/u/leversole)\
**Post date:** [June 21, 2018, 1:00pm UTC](https://forum.inductiveautomation.com/t/creating-array-tags/18554/3 "2018-06-21T13:00:48Z")

</div>

Update

Instead of creating a tag, I drag and dropped into the tag browser and it worked?!? I dont know if I completely understand your reply…

---

<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:** [June 21, 2018, 1:01pm UTC](https://forum.inductiveautomation.com/t/creating-array-tags/18554/4 "2018-06-21T13:01:04Z")

</div>

BTW, if you don’t really need an array type, just access to all of those elements, drag the OPC Item folder to the Tag Browser and release in the spot you want – Ignition will create all 600 tags.

---

<div class="post-metadata">

**Author:** ![leversole](https://avatars.discourse-cdn.com/v4/letter/l/db5fbb/32.png) [@leversole](https://forum.inductiveautomation.com/u/leversole)\
**Post date:** [June 21, 2018, 1:03pm UTC](https://forum.inductiveautomation.com/t/creating-array-tags/18554/5 "2018-06-21T13:03:00Z")

</div>

The main reason for bringing these tags in (temporarily) is to graph them…should I start a new topic or can someone direct me how link an array like this to a chart of some type?

Thanks

---

<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:** [June 21, 2018, 1:10pm UTC](https://forum.inductiveautomation.com/t/creating-array-tags/18554/6 "2018-06-21T13:10:03Z")

</div>

You’ll have to construct a dataset with the values in a column. Something like this:

```auto
tagpattern = '[default]path/to/array/_%d_'
headers = ['Samples']
rows = [[x.value] for x in system.tag.readAll([tagpattern % d for d in range(600)])]
ds = system.dataset.toDataSet(headers, rows)

```

---

<div class="post-metadata">

**Author:** ![leversole](https://avatars.discourse-cdn.com/v4/letter/l/db5fbb/32.png) [@leversole](https://forum.inductiveautomation.com/u/leversole)\
**Post date:** [June 21, 2018, 1:12pm UTC](https://forum.inductiveautomation.com/t/creating-array-tags/18554/7 "2018-06-21T13:12:28Z")

</div>

Thanks! I figured I would have to create a data set!

---

<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:** [June 21, 2018, 1:12pm UTC](https://forum.inductiveautomation.com/t/creating-array-tags/18554/8 "2018-06-21T13:12:34Z")

</div>

I’d put that script in a timer component’s action event, where you can assign the result to your classic chart’s dataset.

---

<div class="post-metadata">

**Author:** ![leversole](https://avatars.discourse-cdn.com/v4/letter/l/db5fbb/32.png) [@leversole](https://forum.inductiveautomation.com/u/leversole)\
**Post date:** [June 21, 2018, 2:53pm UTC](https://forum.inductiveautomation.com/t/creating-array-tags/18554/9 "2018-06-21T14:53:07Z")

</div>

I apologize if it is something simple I am overlooking, I am getting blank rows (no numbers)…

 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/2/268c21b52cda801e8e4c7e364c2dbf1360951218.jpg)

---

<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:** [June 21, 2018, 3:43pm UTC](https://forum.inductiveautomation.com/t/creating-array-tags/18554/10 "2018-06-21T15:43:55Z")

</div>

The pattern doesn’t match the actual names in the tag tree. You need another Bottom\_Raw in there.

---

<div class="post-metadata">

**Author:** ![leversole](https://avatars.discourse-cdn.com/v4/letter/l/db5fbb/32.png) [@leversole](https://forum.inductiveautomation.com/u/leversole)\
**Post date:** [June 21, 2018, 4:25pm UTC](https://forum.inductiveautomation.com/t/creating-array-tags/18554/11 "2018-06-21T16:25:30Z")

</div>

Now I feel like a dummy! Thanks for your help!

---

<div class="post-metadata">

**Author:** ![leversole](https://avatars.discourse-cdn.com/v4/letter/l/db5fbb/32.png) [@leversole](https://forum.inductiveautomation.com/u/leversole)\
**Post date:** [June 21, 2018, 5:21pm UTC](https://forum.inductiveautomation.com/t/creating-array-tags/18554/12 "2018-06-21T17:21:12Z")

</div>

Phil, I feel like I owe you a consulting fee! 😜

Got the dataset portion working, struggling with the code to assign the ds to a charts dataset…

![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/6/6302466e2d4bf1e1f7a1332dcdaafef8f51c7b0e.jpg)

(PS…I used (‘Chart1’).Data above, I copied it when I was trying something else)

I can use this code for a table object, but the three different charts complain…  
Easy Chart…no data property, and I tried DB Pens and Calculated Pens  
Chart complains no attribute data  
Sparkiline says the same…

I thought all charts needed a timestamp?!? Just looking at the way to assign the dataset to a chart…

Thanks

---

<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:** [June 21, 2018, 5:54pm UTC](https://forum.inductiveautomation.com/t/creating-array-tags/18554/13 "2018-06-21T17:54:57Z")

</div>

Use the classic chart. Use its chart configurator to add a dataset. Which will be a custom property name you can use in your script. If you use an XYplot, you’ll need a timestamp column before the value column, which you’d have to create programmatically knowing the interval between your samples. But the other plot types shouldn’t care. You just wouldn’t have an X-axis label/timespan.

---

<div class="post-metadata">

**Author:** ![leversole](https://avatars.discourse-cdn.com/v4/letter/l/db5fbb/32.png) [@leversole](https://forum.inductiveautomation.com/u/leversole)\
**Post date:** [June 21, 2018, 7:14pm UTC](https://forum.inductiveautomation.com/t/creating-array-tags/18554/14 "2018-06-21T19:14:12Z")

</div>

Making sure I understand, when you say classic chart, you mean “Chart” from the components menu correct? (nothing listed as “classic chart”).  
I am really confused, I can only make it an xy chart or a category chart…I got it changed to a category chart and it will still not display, any lines. The dataset for the chart contains a single column of data (it contains the correct data) which I have set for the Y axis in the configurator…the only thing I have been able to do was to manually add a column, and put a few dates in, this worked. IF I must use a date field, can you assist me in the code to, for example, start with now, and add one minute to each record, at least I could get it to display! I under stand that I need to add another field to the headers line  
such as…  
headers =[‘DtTime’, ‘BottomRaw’]  
just not certain how to step thru the rows and write and increment the date.

Thank you again…

---

<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:** [June 21, 2018, 7:57pm UTC](https://forum.inductiveautomation.com/t/creating-array-tags/18554/15 "2018-06-21T19:57:32Z")

</div>

Something like this:

```auto
startMillis = system.date.now().time-600*60000L
tagpattern = '[default]path/to/array/_%d_'
headers = ['t_stamp', 'Samples']
samples = [x.value for x in system.tag.readAll([tagpattern % d for d in range(600)])]
rows = [[system.date.fromMillis(startMillis+60000L*i), v] for i, v in enumerate(samples)]
ds = system.dataset.toDataSet(headers, rows)

```

---

<div class="post-metadata">

**Author:** ![leversole](https://avatars.discourse-cdn.com/v4/letter/l/db5fbb/32.png) [@leversole](https://forum.inductiveautomation.com/u/leversole)\
**Post date:** [June 22, 2018, 6:13pm UTC](https://forum.inductiveautomation.com/t/creating-array-tags/18554/17 "2018-06-22T18:13:00Z")

</div>

It is working as expected, Thank You! I would like to add another column added to the dataset in the same fasion as the current column…have been playing with it and one of the things I cannot get is the v…thought it might be a variable placeholder, but if I add any other letter, it complains that it is not defined, so maybe it is a type, but when I duplicate it, complains still…how are the i and v used without being defined?!? Anyway, here is the code that I think SHOULD work, am I missing something small? syntax?

 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/7/70d4c44f7e6782d3d8bcafe25d7d4f8eb3bab5fe.jpg)

---

<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:** [June 22, 2018, 8:52pm UTC](https://forum.inductiveautomation.com/t/creating-array-tags/18554/18 "2018-06-22T20:52:54Z")

</div>

Those variables are defined by the `for i, v` clause of the list comprehension. You cannot combine two lists in parallel with the syntax you attempted. You need to use python’s zip() function. Like so:

```auto
rows = [[system.date.fromMillis(startMillis+60000L*i), v[0], v[1]] for i, v in enumerate(zip(samples, samples2))]

```

You might want to review the python docs describing [target lists in assignments](https://docs.python.org/2/reference/simple_stmts.html#assignment-statements).

---

<div class="post-metadata">

**Author:** ![Loek](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/loek/32/6730_2.png) [@Loek](https://forum.inductiveautomation.com/u/Loek)\
**Post date:** [May 8, 2019, 11:41am UTC](https://forum.inductiveautomation.com/t/creating-array-tags/18554/19 "2019-05-08T11:41:00Z")

</div>

Phil,

I’ve got almost the same issue, but even with your code I can’t get it working.

I’ve got an array with 100 values and want to visualize it in a Bar Chart.  
So 100 values numbered from 0 till 99.

I adjusted your code:  
The line “tagpattern” is pointing to the tags in my array like the example in the beginning of this topic  
The rest of the code is a combination from above.  
Imho I need also something to write the data from the array to the dataset.

tagpattern = ‘FluidFill/AmountOfFluid/AmountOfFluid\_%d\_’  
headers = [‘Label’, ‘Last\_Fillings’]  
samples = [x.value for x in system.tag.readAll([tagpattern % d for d in range(100)])]  
rows = [(100)]  
ds = system.dataset.toDataSet(headers, rows)  
event.source.parent.getComponent(‘BarChart’).AmoutOfFluid = ds

Can you point me in the right direction?  
I’ve got this script running in a timer script like you mentioned.

Thanks,  
Loek

---

<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:** [May 8, 2019, 12:57pm UTC](https://forum.inductiveautomation.com/t/creating-array-tags/18554/20 "2019-05-08T12:57:23Z")

</div>

Your `rows` variable needs to be a list of lists, with the inner lists being label string & value. To match your headers.
