# System.dataset.addColumn can't convert error

**URL:** <https://forum.inductiveautomation.com/t/system-dataset-addcolumn-cant-convert-error/60824>\
**Category:** Ignition\
**Tags:** ignition81, scripting\
**Created:** [June 16, 2022, 10:30am UTC](https://forum.inductiveautomation.com/t/system-dataset-addcolumn-cant-convert-error/60824 "2022-06-16T10:30:40Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![daniele1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/daniele1/32/31531_2.png) [@daniele1](https://forum.inductiveautomation.com/u/daniele1)\
**Post date:** [June 16, 2022, 10:30am UTC](https://forum.inductiveautomation.com/t/system-dataset-addcolumn-cant-convert-error/60824/1 "2022-06-16T10:30:40Z")

</div>

Hi,  
I’m trying to combine two datasets and I want to use the addColumn method.  
I create a tag history column with a dictionary and the append method then i convert to a dataset and then to a pyDataset, i pass it to the addColumn function but I get an error about the data ype of the column  
Here’s the final part of the code with some prints that you can see in the console

```auto
print col_caravaggio

col_caravaggio = system.dataset.toDataSet(header_caravaggio, col_caravaggio)
print col_caravaggio

#Dataset_finale
pydataset_caravaggio=system.dataset.toPyDataSet(col_caravaggio)
for row in pydataset_caravaggio:
    for value in row:
        print value

dataset_finale=system.dataset.addColumn(dataset_titec, pydataset_caravaggio,"CARAVAGGIO",float)

print dataset_finale

```

 ![immagine](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/7/c7074aeebb11f49e4e8bb71b79fa70bb23a323b6.png)

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [June 16, 2022, 1:29pm UTC](https://forum.inductiveautomation.com/t/system-dataset-addcolumn-cant-convert-error/60824/2 "2022-06-16T13:29:22Z")

</div>

Your are using `addColumn` wrong, it expects a list of values for the column variable. You are passing in an entire dataset.

[system.dataset.addColumn - Ignition User Manual 8.1 - Ignition Documentation (inductiveautomation.com)](https://docs.inductiveautomation.com/display/DOC81/system.dataset.addColumn)

Try

```auto
print col_caravaggio

dataset_finale=system.dataset.addColumn(dataset_titec, col_caravaggio,"CARAVAGGIO",float)

print dataset_finale

```

---

<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:** [June 16, 2022, 1:41pm UTC](https://forum.inductiveautomation.com/t/system-dataset-addcolumn-cant-convert-error/60824/3 "2022-06-16T13:41:05Z")

</div>

> [@daniele1](#):
>
> I create a tag history column with a dictionary and the append method then i convert to a dataset and then to a pyDataset, i pass it to the addColumn function

That seems overly complicated to merge two datasets.  
How do you want them joined ?  
Let's say you have

```python
[
	[a1, a2, a3],
	[b1, b2, b3]
]
[
	[c1, c2, c3],
	[d1, d2, d3]
]

```

do you want this:

```python
[
	[a1, a2, a3],
	[b1, b2, b3],
	[c1, c2, c3],
	[d1, d2, d3]
]

```

or this:

```auto
[
	[a1, a2, a3, c1, c2, c3],
	[b1, b2, b3, d1, d2, d3]
]

```

---

<div class="post-metadata">

**Author:** ![daniele1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/daniele1/32/31531_2.png) [@daniele1](https://forum.inductiveautomation.com/u/daniele1)\
**Post date:** [June 16, 2022, 1:54pm UTC](https://forum.inductiveautomation.com/t/system-dataset-addcolumn-cant-convert-error/60824/4 "2022-06-16T13:54:29Z")

</div>

the second case, i have two datasaet with the same numbers of rows

---

<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:** [June 16, 2022, 2:09pm UTC](https://forum.inductiveautomation.com/t/system-dataset-addcolumn-cant-convert-error/60824/5 "2022-06-16T14:09:58Z")

</div>

```python
a = [
	['a1', 'a2', 'a3'],
	['b1', 'b2', 'b3']
]
b = [
	['a4', 'a5', 'a6'],
	['b4', 'b5', 'b6']
]

[x + y for x, y in zip(a, b)]

```

> `[['a1', 'a2', 'a3', 'a4', 'a5', 'a6'], ['b1', 'b2', 'b3', 'b4', 'b5', 'b6']]`

replace `a` and `b` by your pyDataSets.

Alternatively, you could do it with basic datasets and `addColumn`, but frankly I tend to avoid those as I think they don't integrate well with python.

---

<div class="post-metadata">

**Author:** ![daniele1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/daniele1/32/31531_2.png) [@daniele1](https://forum.inductiveautomation.com/u/daniele1)\
**Post date:** [June 16, 2022, 3:50pm UTC](https://forum.inductiveautomation.com/t/system-dataset-addcolumn-cant-convert-error/60824/6 "2022-06-16T15:50:12Z")

</div>

Thank you,  
i ended up using the addColumn function at the end because is a bit more readeable and probably better for future maintenance.  
For some reason i miread the doc and thought that the function required a pydataset instead of a python list.  
Now it merges two tabels like I want to but the values all comes out with a lot of decimals ( i round them up with 2 decimals before addinf them to the list so it’s a function problems).  
This is the output excel, the last column is the one I added  
 ![immagine](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/e/9e36c6a432905962bdc7269053d213004da4e5bf.png)  
Any way to fix this?

---

<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:** [June 16, 2022, 4:25pm UTC](https://forum.inductiveautomation.com/t/system-dataset-addcolumn-cant-convert-error/60824/7 "2022-06-16T16:25:36Z")

</div>

> [@daniele1](#):
>
> i ended up using the addColumn function at the end because is a bit more readeable and probably better for future maintenance.

more readable than `[x + y for x, y in zip(a, b)]` ?  
I'd be curious to see the code that's more readable than a single list comprehension :X

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [June 16, 2022, 6:47pm UTC](https://forum.inductiveautomation.com/t/system-dataset-addcolumn-cant-convert-error/60824/8 "2022-06-16T18:47:30Z")

</div>

> [@pascal.fragnoud](#):
>
> I’d be curious to see the code that’s more readable than a single list comprehension

Sometimes its not about being terse, but about being able to understand the script especially when you come back to it 6 months down the road.

Granted that is a fairly simple list comprehension, but if one is not use to it, it can look intimidating. A great time to learn it though!
