# Filling a table from 2 other tables

**URL:** <https://forum.inductiveautomation.com/t/filling-a-table-from-2-other-tables/36872>\
**Category:** General Discussion\
**Created:** [July 20, 2020, 5:37pm UTC](https://forum.inductiveautomation.com/t/filling-a-table-from-2-other-tables/36872 "2020-07-20T17:37:19Z")\
**Posts on this page:** 20\
**Page:** 3

<div class="post-metadata">

**Author:** ![toddayers](https://avatars.discourse-cdn.com/v4/letter/t/8baadc/32.png) [@toddayers](https://forum.inductiveautomation.com/u/toddayers)\
**Post date:** [July 24, 2020, 12:30pm UTC](https://forum.inductiveautomation.com/t/filling-a-table-from-2-other-tables/36872/41 "2020-07-24T12:30:37Z")

</div>

Nope… does nothing.

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [July 24, 2020, 12:34pm UTC](https://forum.inductiveautomation.com/t/filling-a-table-from-2-other-tables/36872/42 "2020-07-24T12:34:15Z")

</div>

No errors popping up? Are you using tabs for the indentation?

---

<div class="post-metadata">

**Author:** ![toddayers](https://avatars.discourse-cdn.com/v4/letter/t/8baadc/32.png) [@toddayers](https://forum.inductiveautomation.com/u/toddayers)\
**Post date:** [July 24, 2020, 12:37pm UTC](https://forum.inductiveautomation.com/t/filling-a-table-from-2-other-tables/36872/43 "2020-07-24T12:37:31Z")

</div>

tabs for the indentation?

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [July 24, 2020, 12:38pm UTC](https://forum.inductiveautomation.com/t/filling-a-table-from-2-other-tables/36872/44 "2020-07-24T12:38:43Z")

</div>

The indentation requires tabs instead of spaces.

---

<div class="post-metadata">

**Author:** ![toddayers](https://avatars.discourse-cdn.com/v4/letter/t/8baadc/32.png) [@toddayers](https://forum.inductiveautomation.com/u/toddayers)\
**Post date:** [July 24, 2020, 12:39pm UTC](https://forum.inductiveautomation.com/t/filling-a-table-from-2-other-tables/36872/45 "2020-07-24T12:39:02Z")

</div>

oh … yes I am

---

<div class="post-metadata">

**Author:** ![toddayers](https://avatars.discourse-cdn.com/v4/letter/t/8baadc/32.png) [@toddayers](https://forum.inductiveautomation.com/u/toddayers)\
**Post date:** [July 24, 2020, 12:39pm UTC](https://forum.inductiveautomation.com/t/filling-a-table-from-2-other-tables/36872/46 "2020-07-24T12:39:56Z")

</div>

Is it possible the syntax is different for the newer version?

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [July 24, 2020, 12:43pm UTC](https://forum.inductiveautomation.com/t/filling-a-table-from-2-other-tables/36872/47 "2020-07-24T12:43:01Z")

</div>

I was wondering the same thing between Jython 2.5 and 2.7.

Try this in the Script Console

```python
l = [1,2,3,1]
print l.count(1)

```

I thought list.count() was part of 2.5, but I could be wrong. My wife would say it wouldn’t be the first time. lol.

---

<div class="post-metadata">

**Author:** ![toddayers](https://avatars.discourse-cdn.com/v4/letter/t/8baadc/32.png) [@toddayers](https://forum.inductiveautomation.com/u/toddayers)\
**Post date:** [July 24, 2020, 12:46pm UTC](https://forum.inductiveautomation.com/t/filling-a-table-from-2-other-tables/36872/48 "2020-07-24T12:46:28Z")

</div>

gave me a 2

---

<div class="post-metadata">

**Author:** ![toddayers](https://avatars.discourse-cdn.com/v4/letter/t/8baadc/32.png) [@toddayers](https://forum.inductiveautomation.com/u/toddayers)\
**Post date:** [July 24, 2020, 12:47pm UTC](https://forum.inductiveautomation.com/t/filling-a-table-from-2-other-tables/36872/49 "2020-07-24T12:47:39Z")

</div>

do you do this for a living or something, cause I am no where close to this level of understanding… and my wife tells me the same thing.

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [July 24, 2020, 12:51pm UTC](https://forum.inductiveautomation.com/t/filling-a-table-from-2-other-tables/36872/50 "2020-07-24T12:51:39Z")

</div>

Which it should have done since there’s two '1’s in the list… Okay then.

I’m an end-user, like many of us here. Sometimes, I’ll have time to tinker and learn.

I don’t have a VM with 7.9.x on it at the moment, but I’ll get one spun up and see if we can make this go. 😕

---

<div class="post-metadata">

**Author:** ![toddayers](https://avatars.discourse-cdn.com/v4/letter/t/8baadc/32.png) [@toddayers](https://forum.inductiveautomation.com/u/toddayers)\
**Post date:** [July 24, 2020, 12:55pm UTC](https://forum.inductiveautomation.com/t/filling-a-table-from-2-other-tables/36872/51 "2020-07-24T12:55:36Z")

</div>

I’m an end user also, but I come to this stuff via the automation side. I can program the snot out of PLCs and just about anything Allen Bradley, but the scripting side of this is extremely new to me.

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [July 24, 2020, 12:57pm UTC](https://forum.inductiveautomation.com/t/filling-a-table-from-2-other-tables/36872/52 "2020-07-24T12:57:48Z")

</div>

Well, the big thing to remember is that, as with all programming, it does what we tell it to do, not what we want it to do.

---

<div class="post-metadata">

**Author:** ![toddayers](https://avatars.discourse-cdn.com/v4/letter/t/8baadc/32.png) [@toddayers](https://forum.inductiveautomation.com/u/toddayers)\
**Post date:** [July 24, 2020, 12:58pm UTC](https://forum.inductiveautomation.com/t/filling-a-table-from-2-other-tables/36872/53 "2020-07-24T12:58:55Z")

</div>

Now that sounds like my wife and I…LOL

---

<div class="post-metadata">

**Author:** ![toddayers](https://avatars.discourse-cdn.com/v4/letter/t/8baadc/32.png) [@toddayers](https://forum.inductiveautomation.com/u/toddayers)\
**Post date:** [July 24, 2020, 1:01pm UTC](https://forum.inductiveautomation.com/t/filling-a-table-from-2-other-tables/36872/54 "2020-07-24T13:01:31Z")

</div>

I wonder if this issue is also what is causing the script from the clear button not to work. Because of the columns…

---

<div class="post-metadata">

**Author:** ![toddayers](https://avatars.discourse-cdn.com/v4/letter/t/8baadc/32.png) [@toddayers](https://forum.inductiveautomation.com/u/toddayers)\
**Post date:** [July 24, 2020, 1:02pm UTC](https://forum.inductiveautomation.com/t/filling-a-table-from-2-other-tables/36872/55 "2020-07-24T13:02:45Z")

</div>

I tried using the script you had on the clear button to clear out the table once the information has been transferred to my database and it gave me an error saying:

Traceback (most recent call last):

File “event:actionPerformed”, line 35, in

IndexError: Row 0 doesn’t have the same number of columns as header list.

Ignition v7.9.13 (b2019120915)  
Java: Oracle Corporation 1.8.0\_261

---

<div class="post-metadata">

**Author:** ![MMaynard](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mmaynard/32/3366_2.png) [@MMaynard](https://forum.inductiveautomation.com/u/MMaynard)\
**Post date:** [July 24, 2020, 1:20pm UTC](https://forum.inductiveautomation.com/t/filling-a-table-from-2-other-tables/36872/56 "2020-07-24T13:20:39Z")

</div>

```
if colName=='Name':
	from com.inductiveautomation.ignition.common import BasicDataset
	config = {'background': 'white'}
	data = BasicDataset(self.data)
	compareList = list(data.getColumnAsList(colIndex))
	if compareList.count(value)>1 and value<>None:
		config = {'background':'yellow'}
	return config
```

---

<div class="post-metadata">

**Author:** ![toddayers](https://avatars.discourse-cdn.com/v4/letter/t/8baadc/32.png) [@toddayers](https://forum.inductiveautomation.com/u/toddayers)\
**Post date:** [July 24, 2020, 1:23pm UTC](https://forum.inductiveautomation.com/t/filling-a-table-from-2-other-tables/36872/57 "2020-07-24T13:23:05Z")

</div>

That works! So is it different between 7.9 and 8.0?

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [July 24, 2020, 7:56pm UTC](https://forum.inductiveautomation.com/t/filling-a-table-from-2-other-tables/36872/58 "2020-07-24T19:56:29Z")

</div>

I think it's related here:

> [@getColumnAsList() in 7.9.14](http://forum.inductiveautomation.com/t/getcolumnaslist-in-7-9-14/37063):
>
> Is getColumnAsList() for datasets not longer available? I have a screen that has used it for years and now it is getting an error AttributeError: 'com.inductiveautomation.factorypmi.application.bin' object has no attribute 'getColumnAsList' The error seems to odd to me because the variable is being set to a dataset from a table so why does it say ‘com.inductiveautomation.factorypmi.application.bin’? here is a snip of the code dsData = event.source.parent.getComponent('tblPrices').data header…

---

<div class="post-metadata">

**Author:** ![toddayers](https://avatars.discourse-cdn.com/v4/letter/t/8baadc/32.png) [@toddayers](https://forum.inductiveautomation.com/u/toddayers)\
**Post date:** [July 27, 2020, 1:06pm UTC](https://forum.inductiveautomation.com/t/filling-a-table-from-2-other-tables/36872/59 "2020-07-27T13:06:39Z")

</div>

One last question on this thread: on the clear button you have on the example you provided me, I copied that code to also clear my table once I have submitted my information but I am getting this message:

Traceback (most recent call last):

File “event:actionPerformed”, line 35, in

IndexError: Row 0 doesn’t have the same number of columns as header list.

Ignition v7.9.13 (b2019120915)  
Java: Oracle Corporation 1.8.0\_261

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [July 27, 2020, 1:09pm UTC](https://forum.inductiveautomation.com/t/filling-a-table-from-2-other-tables/36872/60 "2020-07-27T13:09:31Z")

</div>

Try sticking the same import at the top:

```python
from com.inductiveautomation.ignition.common import BasicDataset

```

[Previous page](https://forum.inductiveautomation.com/t/filling-a-table-from-2-other-tables/36872.md?page=2)

[Next page](https://forum.inductiveautomation.com/t/filling-a-table-from-2-other-tables/36872.md?page=4)
