# Output of selected multiple rows from power table

**URL:** <https://forum.inductiveautomation.com/t/output-of-selected-multiple-rows-from-power-table/41625>\
**Category:** Ignition\
**Tags:** vision, scripting, ignition80\
**Created:** [December 17, 2020, 7:56pm UTC](https://forum.inductiveautomation.com/t/output-of-selected-multiple-rows-from-power-table/41625 "2020-12-17T19:56:06Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![yehet73190](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/yehet73190/32/68157_2.png) [@yehet73190](https://forum.inductiveautomation.com/u/yehet73190)\
**Post date:** [December 17, 2020, 7:56pm UTC](https://forum.inductiveautomation.com/t/output-of-selected-multiple-rows-from-power-table/41625/1 "2020-12-17T19:56:06Z")

</div>

I'm using a power table and the users want to select multiple rows (I have this enabled on the property as well)

I want to output the rows they selected as I'm also going to be using this as a filter in one of my bindings.

So far my code is:

> if len(dRow) \>= 2:
> 
> ```
> for index in dRow:
>  
> project = table.data.getValueAt(index, "Project")   
> 
> print project
> 
> ```

When I print this the output is similar to

> Project1  
> Project2

It outputs it like that separately.

I'm trying to output it in a one line where it would show as

> Project1, Project2,

I tried doing

> print project + ","

But that resulted it

> Project1,  
> Project2,

Its close but I want it to be in a one line. What would be the correct concat syntax for this?

Thank you for the help.

---

<div class="post-metadata">

**Author:** ![wking](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/wking/32/21823_2.png) [@wking](https://forum.inductiveautomation.com/u/wking)\
**Post date:** [December 17, 2020, 8:03pm UTC](https://forum.inductiveautomation.com/t/output-of-selected-multiple-rows-from-power-table/41625/2 "2020-12-17T20:03:44Z")

</div>

```auto
projectLst = []
if len(dRow) >= 2:
    for index in dRow:
        projectLst.apend(table.data.getValueAt(index, "Project"))   

print projectLst

```

---

<div class="post-metadata">

**Author:** ![yehet73190](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/yehet73190/32/68157_2.png) [@yehet73190](https://forum.inductiveautomation.com/u/yehet73190)\
**Post date:** [December 17, 2020, 8:09pm UTC](https://forum.inductiveautomation.com/t/output-of-selected-multiple-rows-from-power-table/41625/3 "2020-12-17T20:09:03Z")

</div>

The output of this was

> [u'Project1']  
> [u'Project1', u'Project2']

Thank you, it's close but how come it also printed the "Project1" on the top?

---

<div class="post-metadata">

**Author:** ![wking](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/wking/32/21823_2.png) [@wking](https://forum.inductiveautomation.com/u/wking)\
**Post date:** [December 17, 2020, 8:11pm UTC](https://forum.inductiveautomation.com/t/output-of-selected-multiple-rows-from-power-table/41625/4 "2020-12-17T20:11:22Z")

</div>

Post your whole code.

---

<div class="post-metadata">

**Author:** ![yehet73190](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/yehet73190/32/68157_2.png) [@yehet73190](https://forum.inductiveautomation.com/u/yehet73190)\
**Post date:** [December 17, 2020, 8:14pm UTC](https://forum.inductiveautomation.com/t/output-of-selected-multiple-rows-from-power-table/41625/5 "2020-12-17T20:14:37Z")

</div>

Here's my whole code

> table = event.source.parent.getComponent('Power Table')  
> dRow = table.getSelectedRows()  
> projectLst =
> 
> if len(dRow) == 1:
> 
> ```
> for index in dRow:
>  
> Project = table.data.getValueAt(index, "Project")   
> event.source.parent.getComponent('Power Table').project = Project
> print Project, "1"
> 
> ```
> 
> elif len(dRow) \>= 2:
> 
> ```
> for index in dRow:
>       
> projectLst.append(table.data.getValueAt(index, "Project"))  
> 
> print projectLst
> 
> ```

---

<div class="post-metadata">

**Author:** ![wking](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/wking/32/21823_2.png) [@wking](https://forum.inductiveautomation.com/u/wking)\
**Post date:** [December 17, 2020, 8:16pm UTC](https://forum.inductiveautomation.com/t/output-of-selected-multiple-rows-from-power-table/41625/6 "2020-12-17T20:16:48Z")

</div>

> [@yehet73190](#):
>
> table = event.source.parent.getComponent(‘Power Table’)  
> dRow = table.getSelectedRows()  
> projectLst =
> 
> if len(dRow) == 1:
> 
> ```python
> for index in dRow:
>  
> Project = table.data.getValueAt(index, "Project")   
> event.source.parent.getComponent('Power Table').project = Project
> print Project, "1"
> 
> ```
> 
> elif len(dRow) \>= 2:
> 
> ```python
> for index in dRow:
>       
> projectLst.append(table.data.getValueAt(index, "Project"))  
> 
> print projectLst #<-----------
> 
> ```

Dedent print. You're printing inside a loop and you don't want to be.

---

<div class="post-metadata">

**Author:** ![yehet73190](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/yehet73190/32/68157_2.png) [@yehet73190](https://forum.inductiveautomation.com/u/yehet73190)\
**Post date:** [December 17, 2020, 8:25pm UTC](https://forum.inductiveautomation.com/t/output-of-selected-multiple-rows-from-power-table/41625/7 "2020-12-17T20:25:22Z")

</div>

ahhh its always the smallest things lol. Thank you

How do I get rid of the "u" and square brackets next to it?

> [u’Project1’, u’Project2’]

I tried adding "str" at the end

> str(projectLst)

but it didn't work.

---

<div class="post-metadata">

**Author:** ![wking](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/wking/32/21823_2.png) [@wking](https://forum.inductiveautomation.com/u/wking)\
**Post date:** [December 17, 2020, 8:34pm UTC](https://forum.inductiveautomation.com/t/output-of-selected-multiple-rows-from-power-table/41625/8 "2020-12-17T20:34:21Z")

</div>

the u doesn’t mean anything. Its just saying its a Unicode object.

```auto

print ' '.join(projectLst)

```

---

<div class="post-metadata">

**Author:** ![yehet73190](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/yehet73190/32/68157_2.png) [@yehet73190](https://forum.inductiveautomation.com/u/yehet73190)\
**Post date:** [December 17, 2020, 8:36pm UTC](https://forum.inductiveautomation.com/t/output-of-selected-multiple-rows-from-power-table/41625/9 "2020-12-17T20:36:30Z")

</div>

You’re awesome, thank you!

---

<div class="post-metadata">

**Author:** ![yehet73190](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/yehet73190/32/68157_2.png) [@yehet73190](https://forum.inductiveautomation.com/u/yehet73190)\
**Post date:** [December 17, 2020, 9:15pm UTC](https://forum.inductiveautomation.com/t/output-of-selected-multiple-rows-from-power-table/41625/10 "2020-12-17T21:15:09Z")

</div>

Hi again, sorry im just a little lost, when using **.join** how can I modify this so that each of the string that was split into has an apostrophe, so that it would look like this:

> 'Project1', 'Project2'

---

<div class="post-metadata">

**Author:** ![wking](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/wking/32/21823_2.png) [@wking](https://forum.inductiveautomation.com/u/wking)\
**Post date:** [December 17, 2020, 9:18pm UTC](https://forum.inductiveautomation.com/t/output-of-selected-multiple-rows-from-power-table/41625/11 "2020-12-17T21:18:35Z")

</div>

No worries lol

```auto
print ",".join(projectLst)

```

---

<div class="post-metadata">

**Author:** ![wking](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/wking/32/21823_2.png) [@wking](https://forum.inductiveautomation.com/u/wking)\
**Post date:** [December 17, 2020, 9:20pm UTC](https://forum.inductiveautomation.com/t/output-of-selected-multiple-rows-from-power-table/41625/12 "2020-12-17T21:20:49Z")

</div>

```auto

print "'" + "', '".join(projectLst) + "'"

```

> > > 'Project 1', 'Project 2'

```auto

```

---

<div class="post-metadata">

**Author:** ![yehet73190](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/yehet73190/32/68157_2.png) [@yehet73190](https://forum.inductiveautomation.com/u/yehet73190)\
**Post date:** [December 17, 2020, 9:24pm UTC](https://forum.inductiveautomation.com/t/output-of-selected-multiple-rows-from-power-table/41625/13 "2020-12-17T21:24:02Z")

</div>

Yey bless you! Thank you again! 🤗

---

<div class="post-metadata">

**Author:** ![wking](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/wking/32/21823_2.png) [@wking](https://forum.inductiveautomation.com/u/wking)\
**Post date:** [December 17, 2020, 9:26pm UTC](https://forum.inductiveautomation.com/t/output-of-selected-multiple-rows-from-power-table/41625/14 "2020-12-17T21:26:06Z")

</div>

You probably dont want the space in there. use this instead.

```auto
print "'" + "','".join(projectLst) + "'"

```

---

<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:** [December 17, 2020, 10:52pm UTC](https://forum.inductiveautomation.com/t/output-of-selected-multiple-rows-from-power-table/41625/15 "2020-12-17T22:52:49Z")

</div>

A variation on the same idea:  
`print ",".join("'%s'" % project for project in projectLst)`
