# Problem using system.dataset.addColumn

**URL:** <https://forum.inductiveautomation.com/t/problem-using-system-dataset-addcolumn/8388>\
**Category:** Ignition\
**Created:** [April 29, 2014, 9:29pm UTC](https://forum.inductiveautomation.com/t/problem-using-system-dataset-addcolumn/8388 "2014-04-29T21:29:42Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![shreyaslimaye](https://avatars.discourse-cdn.com/v4/letter/s/f19dbf/32.png) [@shreyaslimaye](https://forum.inductiveautomation.com/u/shreyaslimaye)\
**Post date:** [April 29, 2014, 9:29pm UTC](https://forum.inductiveautomation.com/t/problem-using-system-dataset-addcolumn/8388/1 "2014-04-29T21:29:42Z")

</div>

Hello,

I am trying to add a column into a dataset using the system.dataset.addColumn function and I am running into a problem.

I have the following data with me-  
tracedata = system.tag.queryTagHistory(tagPaths,startts,stopts,numsec)  
tracedata1 = system.dataset.toPyDataSet(tracedata)  
tracedata2 = system.dataset.toDataSet(tracedata1)

tracedata, tracedata1 and tracedata2 have 10 rows and 3 columns. For each row, I need to add a new column titled ‘newcol’ and add a fixed number 123456 to the tracedata2 dataset. I use the following code in order to create the pysequence column necessary for use in the system.dataset.addColumn function

value = 123456  
valueset = []  
for i in range(0,9):  
valueset.append([str(value)])

Then I try using the system.dataset.addColumn function as follows:  
system.dataset.addColumn(tracedata2,valueset,“newcol”,type(""))

However, I get an error saying TypeError: toDataSet(): 1st arg can’t be coerced to com.inductiveautomation.ignition.common.script.builtin.DatasetUtilities$PyDataSet

Looks like valueset is a list and not a pysequence. How can I make valueset into a pysequence column?

Thanks,

Shreyas

---

<div class="post-metadata">

**Author:** ![adamaustin](https://avatars.discourse-cdn.com/v4/letter/a/5f8ce5/32.png) [@adamaustin](https://forum.inductiveautomation.com/u/adamaustin)\
**Post date:** [April 29, 2014, 9:34pm UTC](https://forum.inductiveautomation.com/t/problem-using-system-dataset-addcolumn/8388/2 "2014-04-29T21:34:31Z")

</div>

Try from [types](https://docs.python.org/2/library/types.html):

```auto
from types import *

print type("hi") is StringType
```

---

<div class="post-metadata">

**Author:** ![shreyaslimaye](https://avatars.discourse-cdn.com/v4/letter/s/f19dbf/32.png) [@shreyaslimaye](https://forum.inductiveautomation.com/u/shreyaslimaye)\
**Post date:** [April 29, 2014, 9:56pm UTC](https://forum.inductiveautomation.com/t/problem-using-system-dataset-addcolumn/8388/3 "2014-04-29T21:56:51Z")

</div>

Thanks!

I ran into a different problem now. I am trying to add a column into a dataset using the system.dataset.addColumn function.

I have the following data with me-  
tracedata = system.tag.queryTagHistory(tagPaths,startts,stopts,numsec)  
tracedata1 = system.dataset.toPyDataSet(tracedata)  
tracedata2 = system.dataset.toDataSet(tracedata1)

tracedata, tracedata1 and tracedata2 have 10 rows and 3 columns. For each row, I need to add a new column titled ‘newcol’ and add a fixed number 123456 to the tracedata2 dataset. I use the following code in order to create the pysequence column necessary for use in the system.dataset.addColumn function

value = 123456  
valueset = []  
for i in range(0,9):  
valueset.append([str(value)])

Then I try using the system.dataset.addColumn function as follows:  
system.dataset.addColumn(tracedata2,valueset,“newcol”,type(""))

However, I get an error saying TypeError: toDataSet(): 1st arg can’t be coerced to com.inductiveautomation.ignition.common.script.builtin.DatasetUtilities$PyDataSet

Looks like valueset is a list and not a pysequence. How can I make valueset into a pysequence column?

Thanks,

Shreyas

---

<div class="post-metadata">

**Author:** ![adamaustin](https://avatars.discourse-cdn.com/v4/letter/a/5f8ce5/32.png) [@adamaustin](https://forum.inductiveautomation.com/u/adamaustin)\
**Post date:** [April 29, 2014, 9:59pm UTC](https://forum.inductiveautomation.com/t/problem-using-system-dataset-addcolumn/8388/4 "2014-04-29T21:59:58Z")

</div>

You need a PyDataset:

```auto
system.dataset.addColumn(tracedata1,valueset,"newcol",type(""))
```

EDIT:

Wait. I was confused. Try this:

```auto
tracedata = system.dataset.addColumn(tracedata,valueset,"newcol",type(""))
```

---

<div class="post-metadata">

**Author:** ![shreyaslimaye](https://avatars.discourse-cdn.com/v4/letter/s/f19dbf/32.png) [@shreyaslimaye](https://forum.inductiveautomation.com/u/shreyaslimaye)\
**Post date:** [April 29, 2014, 11:00pm UTC](https://forum.inductiveautomation.com/t/problem-using-system-dataset-addcolumn/8388/5 "2014-04-29T23:00:53Z")

</div>

Thank you very much! When I try  
tracedata = system.dataset.addColumn(tracedata,valueset,“newcol”,type("")),  
I get an error message saying TypeError: toDataSet(): 1st arg can’t be coerced to com.inductiveautomation.ignition.common.script.builtin.DatasetUtilities$PyDataSet

Ignition is considering valueset as a list but is expecting a pysequence column for the system.dataset.addColumn function to work.

The way I am creating valueset is as follows. For each row in tracedata, I need to add a new column titled ‘newcol’ and add a fixed number 123456 to the tracedata dataset.

value = 123456  
valueset = []  
for i in range(0,9):  
valueset.append([str(value)])

How should I define valueset so that it is considered as a pysequence column and not a list?

Thanks,  
Shreyas

---

<div class="post-metadata">

**Author:** ![jpark](https://avatars.discourse-cdn.com/v4/letter/j/a88e57/32.png) [@jpark](https://forum.inductiveautomation.com/u/jpark)\
**Post date:** [April 30, 2014, 3:05pm UTC](https://forum.inductiveautomation.com/t/problem-using-system-dataset-addcolumn/8388/6 "2014-04-30T15:05:57Z")

</div>

This works in 7.6.6

[code]value = 123456  
valueset = []  
for i in range(0,10):  
valueset.append(str(value))

newds = system.dataset.addColumn(tracedata2,valueset,“newcol”,str)[/code]

---

<div class="post-metadata">

**Author:** ![shreyaslimaye](https://avatars.discourse-cdn.com/v4/letter/s/f19dbf/32.png) [@shreyaslimaye](https://forum.inductiveautomation.com/u/shreyaslimaye)\
**Post date:** [April 30, 2014, 8:40pm UTC](https://forum.inductiveautomation.com/t/problem-using-system-dataset-addcolumn/8388/7 "2014-04-30T20:40:20Z")

</div>

Thank you Jae! It worked!

Shreyas
