# Return tag name script

**URL:** <https://forum.inductiveautomation.com/t/return-tag-name-script/45684>\
**Category:** Ignition\
**Tags:** scripting\
**Created:** [April 16, 2021, 2:38pm UTC](https://forum.inductiveautomation.com/t/return-tag-name-script/45684 "2021-04-16T14:38:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kevin\_DLeon](https://avatars.discourse-cdn.com/v4/letter/k/c4cdca/32.png) [@Kevin\_DLeon](https://forum.inductiveautomation.com/u/Kevin_DLeon)\
**Post date:** [April 16, 2021, 2:38pm UTC](https://forum.inductiveautomation.com/t/return-tag-name-script/45684/1 "2021-04-16T14:38:29Z")

</div>

Hello

i have made a csv file with some bunch of tags using “system.tag.browseTags” in a folder and i can get their values with “system.tag.readBlocking” and then with a for function with “.value”, but how can i get in my CSV file only the name of tag example:  
Tank 1 – 120  
instead of  
[Edge]/tanks/tank 1 – 120

regards

---

<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:** [April 16, 2021, 2:49pm UTC](https://forum.inductiveautomation.com/t/return-tag-name-script/45684/2 "2021-04-16T14:49:52Z")

</div>

I’m not entirely sure what you’re trying to do, it seems like you are writing out to a file. Instead of using the full path you want only the actual tag name?

`system.tag.browseTags()` returns a list of BrowseTag objects, you can call the the name variable from that.

```auto
tags = system.tag.browseTags(parentPath="")

for tag in tags:
    print tag.name

```

---

<div class="post-metadata">

**Author:** ![Kevin\_DLeon](https://avatars.discourse-cdn.com/v4/letter/k/c4cdca/32.png) [@Kevin\_DLeon](https://forum.inductiveautomation.com/u/Kevin_DLeon)\
**Post date:** [April 16, 2021, 3:13pm UTC](https://forum.inductiveautomation.com/t/return-tag-name-script/45684/3 "2021-04-16T15:13:26Z")

</div>

wow thank you! it works but; i could not pass it yet to an array, i tried that my CSV file dont show the paths.  
i have something like this:  
tags = system.tag.browseTags(parentPath=“folder”)  
name\_list=[]  
for tag in tags:  
name\_list.append( tags[tag].name )

but it gives me error about “TypeError: array.array indices must be integers”  
PD sorry i did not know how to use the code format ` `

---

<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:** [April 16, 2021, 3:18pm UTC](https://forum.inductiveautomation.com/t/return-tag-name-script/45684/4 "2021-04-16T15:18:25Z")

</div>

> [@Kevin\_DLeon](#):
>
> PD sorry i did not know how to use the code format

either use three back ticks ``` before and after the code or the preformatted text option to enter code.

> [@Kevin\_DLeon](#):
>
> “TypeError: array.array indices must be integers”

This is because tag isn't an integer, but an object of type browseTag

This should get you a list of names:

```auto
tags = system.tag.browseTags(parentPath='folder')
name_list = [tag.name for tag in tags]

```

---

<div class="post-metadata">

**Author:** ![Kevin\_DLeon](https://avatars.discourse-cdn.com/v4/letter/k/c4cdca/32.png) [@Kevin\_DLeon](https://forum.inductiveautomation.com/u/Kevin_DLeon)\
**Post date:** [April 16, 2021, 3:20pm UTC](https://forum.inductiveautomation.com/t/return-tag-name-script/45684/5 "2021-04-16T15:20:09Z")

</div>

thank you, thank yo so much for your time! it works 😃
