# Merge 2 dataset in to single dataset

**URL:** <https://forum.inductiveautomation.com/t/merge-2-dataset-in-to-single-dataset/73646>\
**Category:** Ignition\
**Tags:** vision\
**Created:** [May 12, 2023, 12:42pm UTC](https://forum.inductiveautomation.com/t/merge-2-dataset-in-to-single-dataset/73646 "2023-05-12T12:42:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![prasath.t](https://avatars.discourse-cdn.com/v4/letter/p/898d66/32.png) [@prasath.t](https://forum.inductiveautomation.com/u/prasath.t)\
**Post date:** [May 12, 2023, 12:42pm UTC](https://forum.inductiveautomation.com/t/merge-2-dataset-in-to-single-dataset/73646/1 "2023-05-12T12:42:25Z")

</div>

Hi  
i have 2 dataset and i want to merge 2 dataset in to single dataset

**which is the easiest way to do it?**

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/a/f/afe2ebcac45460ed9a42d8f210b3fd5c7b2c4d08.png)

1 dataset have 3 columns  
2 dataset have 2 columns

**i want final out with single dataset with 200R\*5C**

---

<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:** [May 12, 2023, 12:46pm UTC](https://forum.inductiveautomation.com/t/merge-2-dataset-in-to-single-dataset/73646/2 "2023-05-12T12:46:17Z")

</div>

Use `system.dataset.addColumn()` in conjunction with the `getColumnAsList()` function on the dataset to add the columns from one dataset to the other.

---

<div class="post-metadata">

**Author:** ![prasath.t](https://avatars.discourse-cdn.com/v4/letter/p/898d66/32.png) [@prasath.t](https://forum.inductiveautomation.com/u/prasath.t)\
**Post date:** [May 12, 2023, 1:23pm UTC](https://forum.inductiveautomation.com/t/merge-2-dataset-in-to-single-dataset/73646/3 "2023-05-12T13:23:34Z")

</div>

Tired below code but getting error

```auto
columnData = []
ds1 = event.source.parent.getComponent('Power Table').data
ds2 = event.source.parent.getComponent('Power Table 1').data
col_name = ds2.getColumnNames()

col_type = ds2.getColumnTypes()
colCount = ds2.getRowCount()
for i in range(ds2.getColumnCount()):
 	columnData = ds2.getColumnAsList(i)
	ds2 = system.dataset.addColumn(ds1, colCount, columnData, col_name[i], col_type[i])

```

error:

```auto
TypeError: addColumn(): 3rd arg can't be coerced to org.python.core.PySequence

	at org.python.core.Py.TypeError(Py.java:236)
	at org.python.core.PyReflectedFunction.throwError(PyReflectedFunction.java:213)
	at org.python.core.PyReflectedFunction.throwBadArgError(PyReflectedFunction.java:316)
	at org.python.core.PyReflectedFunction.throwError(PyReflectedFunction.java:325)
	at org.python.core.PyReflectedFunction. __call__ (PyReflectedFunction.java:171)
	at org.python.core.PyReflectedFunction. __call__ (PyReflectedFunction.java:208)
	at org.python.core.PyObject. __call__ (PyObject.java:433)
	at org.python.core.PyObject. __call__ (PyObject.java:437)
	at org.python.pycode._pyx833.f$0(<event:mouseClicked>:12)
	at org.python.pycode._pyx833.call_function(<event:mouseClicked>)
	at org.python.core.PyTableCode.call(PyTableCode.java:173)
	at org.python.core.PyCode.call(PyCode.java:18)
	at org.python.core.Py.runCode(Py.java:1687)
	at com.inductiveautomation.ignition.common.script.ScriptManager.runCode(ScriptManager.java:788)
	at com.inductiveautomation.factorypmi.application.binding.action.ActionAdapter.runActions(ActionAdapter.java:206)
	at com.inductiveautomation.factorypmi.application.binding.action.ActionAdapter.invoke(ActionAdapter.java:299)
	at com.inductiveautomation.factorypmi.application.binding.action.RelayInvocationHandler.invoke(RelayInvocationHandler.java:57)
	at com.sun.proxy.$Proxy57.mouseClicked(Unknown Source)
	at java.desktop/java.awt.AWTEventMulticaster.mouseClicked(Unknown Source)
	at java.desktop/java.awt.Component.processMouseEvent(Unknown Source)
	at java.desktop/javax.swing.JComponent.processMouseEvent(Unknown Source)
	at java.desktop/java.awt.Component.processEvent(Unknown Source)
	at java.desktop/java.awt.Container.processEvent(Unknown Source)
	at java.desktop/java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.desktop/java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.desktop/java.awt.Component.dispatchEvent(Unknown Source)
	at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
	at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
	at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
	at java.desktop/java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.desktop/java.awt.Window.dispatchEventImpl(Unknown Source)
	at java.desktop/java.awt.Component.dispatchEvent(Unknown Source)
	at java.desktop/java.awt.EventQueue.dispatchEventImpl(Unknown Source)
	at java.desktop/java.awt.EventQueue$4.run(Unknown Source)
	at java.desktop/java.awt.EventQueue$4.run(Unknown Source)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
	at java.desktop/java.awt.EventQueue$5.run(Unknown Source)
	at java.desktop/java.awt.EventQueue$5.run(Unknown Source)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
	at java.desktop/java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.run(Unknown Source)
Caused by: org.python.core.PyException: TypeError: addColumn(): 3rd arg can't be coerced to org.python.core.PySequence
	... 49 common frames omitted

```

---

<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:** [May 12, 2023, 1:46pm UTC](https://forum.inductiveautomation.com/t/merge-2-dataset-in-to-single-dataset/73646/4 "2023-05-12T13:46:44Z")

</div>

You should use code similar to this:

```auto
for i, name in enumerate(ds2.columnNames):
    ds1 = system.dataset.addColumn(ds1,ds1.columnCount,list(ds2.getColumnAsList(i)),name,ds2.getColumnType(i))

```
