# Browse all tags of certain name and export to Dataset

**URL:** <https://forum.inductiveautomation.com/t/browse-all-tags-of-certain-name-and-export-to-dataset/27763>\
**Category:** Ignition\
**Created:** [August 26, 2019, 3:34pm UTC](https://forum.inductiveautomation.com/t/browse-all-tags-of-certain-name-and-export-to-dataset/27763 "2019-08-26T15:34:46Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![connorcarey](https://avatars.discourse-cdn.com/v4/letter/c/46a35a/32.png) [@connorcarey](https://forum.inductiveautomation.com/u/connorcarey)\
**Post date:** [August 26, 2019, 3:34pm UTC](https://forum.inductiveautomation.com/t/browse-all-tags-of-certain-name-and-export-to-dataset/27763/1 "2019-08-26T15:34:46Z")

</div>

Hi,

I’m trying to browse through all of my tags and read all of the tags named “override” i have in valve tag folders that currently have the state “False” (Every valve has a folder, with common tags such as “override”, “open”, “close” etc).

Currently I am able to navigate down through folders and subfolders using system.tag.browseTags

```auto
tags = system.tag.browseTags(parentPath="[SQLTags]AcuteManualFilling/MainProgram", tagPath="*XCV*")
for tag in tags:
	c = tag.fullPath
	
    	tags1 = system.tag.browseTags(parentPath=(c), tagPath="*Override*")
    	for tag in tags1:
		#	print tag.name
			a = tag.fullPath

```

This returns the following (Which is what I want to see)

```auto

[u'AcuteManualFilling/MainProgram/XCV857/Override']
[u'AcuteManualFilling/MainProgram/XCV856/Override']
[u'AcuteManualFilling/MainProgram/XCV855/Override']
[u'AcuteManualFilling/MainProgram/XCV854/Override']
[u'AcuteManualFilling/MainProgram/XCV853/Override']
[u'AcuteManualFilling/MainProgram/XCV852/Override']
[u'AcuteManualFilling/MainProgram/XCV859/Override']
[u'AcuteManualFilling/MainProgram/XCV858/Override']

```

I then use system.tag.read(a).value, which tells me if the tag is True or False.

I use an IF statement and in this I want to append the tag path to a dataSet, to list all of the override tags that are “False”

```auto
c = tag.path
			if values == False:
 				#print c
 				header = ["Valve"]
				data = []
				data.append(c)
				#print data	

			overrides = system.dataset.toDataSet(header, [data])

```

However, only one line appends to the dataset (the first tag detected):  
`u'AcuteManualFilling/MainProgram/XCV857/Override'`

Is there a way to populate multiple rows with every override tag path that has been detected as False?

---

<div class="post-metadata">

**Author:** ![nick.schuetz](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nick.schuetz/32/6160_2.png) [@nick.schuetz](https://forum.inductiveautomation.com/u/nick.schuetz)\
**Post date:** [August 26, 2019, 4:05pm UTC](https://forum.inductiveautomation.com/t/browse-all-tags-of-certain-name-and-export-to-dataset/27763/2 "2019-08-26T16:05:25Z")

</div>

It looks like the data is being reinitialized to empty inside of your loop. The data and header initialization should be placed outside of the loop. Try something like this instead (not tested).

```auto
header = ['Valve']
data = []
for tag in tags:
    value = system.tag.read(tag.path).value
    if value == False:
		c = tag.path
		#print c
		data.append(c)
#print data

```

---

<div class="post-metadata">

**Author:** ![connorcarey](https://avatars.discourse-cdn.com/v4/letter/c/46a35a/32.png) [@connorcarey](https://forum.inductiveautomation.com/u/connorcarey)\
**Post date:** [August 27, 2019, 3:07pm UTC](https://forum.inductiveautomation.com/t/browse-all-tags-of-certain-name-and-export-to-dataset/27763/3 "2019-08-27T15:07:36Z")

</div>

Hey Nick,

Thanks for the response. I am getting the following output:

[SQLTags]AcuteManualFilling/MainProgram/XCV857/Override  
AcuteManualFilling/MainProgram/XCV857/Override  
Traceback (most recent call last):  
File “”, line 20, in   
IndexError: Row 0 doesn’t have the same number of columns as header list.

So it still seems to be only catching the first “Override” instance it sees.

As for the indexError. Does the number of rows in a dataset need to be specified? Does it not just auto append each “Override” valve as a new row (Atleast that’s what I want to happen!)

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [August 27, 2019, 3:32pm UTC](https://forum.inductiveautomation.com/t/browse-all-tags-of-certain-name-and-export-to-dataset/27763/4 "2019-08-27T15:32:20Z")

</div>

You’re both halfway right. You _do_ need to initialize `data` outside the loop - however, you _also_ want to append each row as it’s own row object, due to the way `system.dataset.toDataSet` works; you need to construct a “two dimensional” array, which in Python is represented as a list of lists:

```python
[
  [1], # row1 - should be as many elements as there will be columns in the output
  [2], # row2 - must match row1's length
  [3] # row3
]

```

Leave data as @nick.schuetz had it - initialize it as an empty list before starting the loop. Then change the line after `header = ["Valve"]` to `data.append([c])` - `data` will be your _list of rows_, and then you will append _each row_ to it, as a unique list.  
Then drop the square brackets in the call to `system.dataset.toDataSet`, since you already have a 2d array/list.

---

<div class="post-metadata">

**Author:** ![connorcarey](https://avatars.discourse-cdn.com/v4/letter/c/46a35a/32.png) [@connorcarey](https://forum.inductiveautomation.com/u/connorcarey)\
**Post date:** [August 30, 2019, 11:05am UTC](https://forum.inductiveautomation.com/t/browse-all-tags-of-certain-name-and-export-to-dataset/27763/5 "2019-08-30T11:05:33Z")

</div>

Thanks @paul-griffith!

It worked a charm and thanks for the informative explanation
