# Displaying a list from a tag read

**URL:** <https://forum.inductiveautomation.com/t/displaying-a-list-from-a-tag-read/78078>\
**Category:** Ignition\
**Tags:** ignition81, perspective\
**Created:** [August 18, 2023, 1:46pm UTC](https://forum.inductiveautomation.com/t/displaying-a-list-from-a-tag-read/78078 "2023-08-18T13:46:27Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mjohnson0238](https://avatars.discourse-cdn.com/v4/letter/m/4bbf92/32.png) [@mjohnson0238](https://forum.inductiveautomation.com/u/mjohnson0238)\
**Post date:** [August 18, 2023, 1:46pm UTC](https://forum.inductiveautomation.com/t/displaying-a-list-from-a-tag-read/78078/1 "2023-08-18T13:46:27Z")

</div>

I have this python code that reads through a list of tags then returns the tag list back to me in this format TW1,Quad\_A,B,C or D wherever the opnum is found at

```auto
	from itertools import product
	
	def get_iterator(op_strings):
	    quads = ['A', 'B', 'C', 'D']
	    return product(range(1, 66), quads, op_strings)
	shift = system.tag.readBlocking("[default]Twisters/Selected Shift From Assigner")[0].value
	path = '[default]Twisters/TW{}/Operator Assignments/Quad_{} '+str(shift)+' Shift Operator {}'
	paths = [path.format(*p) for p in get_iterator(['Name', 'BadgeNum'])]
	tag_qvals = system.tag.readBlocking(paths)
	opnum = self.props.text #'0008161371'
	
	# Filter and extract TW and Quad from matching paths
	matching_paths = [p for p, q in zip(paths, tag_qvals) if q.value == opnum]
	for matching_path in matching_paths:
	    parts = matching_path.split('/')
	    twister_number = parts[1][2:] # Extract the number from 'TW1'
	    quad_part = parts[3].split()[0] # Get the Quad part before the space
	    self.getSibling("TextArea_3").props.text = ('TW{}, {}'.format(twister_number, quad_part))

```

When I print the result in the console I get a row for each output, in this case it looks like this:  
TW1, Quad\_B  
TW1, Quad\_C  
TW1, Quad\_D

BUT when I try and have that same returned to a label or textarea it returns only the last output, TW1,Quad\_D.

How do i have return all the outputs?

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [August 18, 2023, 2:01pm UTC](https://forum.inductiveautomation.com/t/displaying-a-list-from-a-tag-read/78078/2 "2023-08-18T14:01:28Z")

</div>

I think your user requirements could be improved. I can't make any sense of it!

> The first text field takes the input and writes the [1:11] to the label ...

Are they both text fields? Why different fonts?  
There is no [1:11] in your screengrabs.  
"... to the label ...". What label?

Hit the edit icon below the post ...

---

<div class="post-metadata">

**Author:** ![mjohnson0238](https://avatars.discourse-cdn.com/v4/letter/m/4bbf92/32.png) [@mjohnson0238](https://forum.inductiveautomation.com/u/mjohnson0238)\
**Post date:** [August 18, 2023, 5:37pm UTC](https://forum.inductiveautomation.com/t/displaying-a-list-from-a-tag-read/78078/3 "2023-08-18T17:37:08Z")

</div>

I wound up doing this, its works ok for me:

```auto
	from itertools import product
	
	def get_iterator(op_strings):
	    quads = ['A', 'B', 'C', 'D']
	    return product(range(1, 66), quads, op_strings)
	shift = system.tag.readBlocking("[default]Twisters/Selected Shift From Assigner")[0].value
	path = '[default]Twisters/TW{}/Operator Assignments/Quad_{} '+str(shift)+' Shift Operator {}'
	paths = [path.format(*p) for p in get_iterator(['Name', 'BadgeNum'])]
	tag_qvals = system.tag.readBlocking(paths)
	opnum = self.props.text #'0008161371'
	
	# Filter and extract TW and Quad from matching paths
	matching_paths = [p for p, q in zip(paths, tag_qvals) if q.value == opnum]
	# Concatenate the matching paths into a single string
	output_string = ", ".join([
	    'TW{} {}'.format(p.split('/')[1][2:], p.split('/')[3].split()[0])
	    for p in matching_paths
	])
	self.getSibling("TextArea_3").props.text = (output_string)

```

---

<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:** [August 18, 2023, 5:37pm UTC](https://forum.inductiveautomation.com/t/displaying-a-list-from-a-tag-read/78078/4 "2023-08-18T17:37:32Z")

</div>

> [@mjohnson0238](#):
>
> BUT when I try and have that same returned to a label or textarea it returns only the last output, TW1,Quad\_D.

My guess is that you're doing something like that:

```python
for element in list:
    some_var = some_part_of_element
return some_var

```

Am I close ?

That's a big list of values, I'd probably use a table to display that.
