# How to fix AttributeError: 'com.inductiveautomation.ignition.designer.gui.tool' object has no attribute 'toDataset'

**URL:** <https://forum.inductiveautomation.com/t/how-to-fix-attributeerror-com-inductiveautomation-ignition-designer-gui-tool-object-has-no-attribute-todataset/52084>\
**Category:** Ignition\
**Tags:** ignition81, database, scripting\
**Created:** [October 18, 2021, 10:16pm UTC](https://forum.inductiveautomation.com/t/how-to-fix-attributeerror-com-inductiveautomation-ignition-designer-gui-tool-object-has-no-attribute-todataset/52084 "2021-10-18T22:16:23Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![jill.zhao](https://avatars.discourse-cdn.com/v4/letter/j/4bbf92/32.png) [@jill.zhao](https://forum.inductiveautomation.com/u/jill.zhao)\
**Post date:** [October 18, 2021, 10:16pm UTC](https://forum.inductiveautomation.com/t/how-to-fix-attributeerror-com-inductiveautomation-ignition-designer-gui-tool-object-has-no-attribute-todataset/52084/1 "2021-10-18T22:16:23Z")

</div>

Hi ,I have rewrite the excel file to create a memory dataset type tag in ignition, but I could not create a new dataset , could you please help to check which is wrong and how to fix it, Thanks

```auto
import math
from org.apache.commons.math3.analysis.function import Log, Log10
def finaloutput():
	#print("Starting Calculation")
	input= system.tag.read("[default]input").value
	pipeline_inputs = system.tag.read("[default]pipeline_inputs").value
	output1 = system.tag.read("[default]output1").value
	pyds1 =system.dataset.toPyDataSet(output1)
	pyds2 =system.dataset.toPyDataSet(input)
	pyds3 =system.dataset.toPyDataSet(pipeline_inputs)
	OD = pyds3[0][1]
	WT = pyds3[1][1]
	C= pyds3[3][1]
	m= pyds3[4][1]
	Load_Array=[]
	for column in pyds2:
		value=column[1]
		Load_Array.append(value)      
	#34685
	number_of_loads = output1.getRowCount()
	#U column
	urange=[]
	for column in pyds1:
		Range=column[1]
		urange.append(Range)
	#print urange
	#W column
	wcycles=[]
	for column in pyds1:
		Cycles=column[3]
		wcycles.append(Cycles) 
	#print wcycles
	pressure_range=[]
	for i in range(0,1210,10):
		pressure_range.append(i)
	#sum of cycles 
	Sum_w=[0]*120
	for i in range(0,120):
		for j in range(0,number_of_loads):
			if 10*i<urange[j]<=10*(i+1):
				Sum_w[i]=Sum_w[i]+wcycles[j]
	Sum_w.insert(0,0)
	stressrange=[]
	j=0
	for j in range(len(pressure_range)):
		stressvalue=(pressure_range[j])*OD/(2*WT)
		j+=1
		stressrange.append(int(round(stressvalue)))
#	x=1
#	N=[]
#	x10=Log10()
#	for x in range(1,len(stressrange)):
# logval=stressrange[x]/1000
# Cycles=x10.value(logval)
# nvalue=math.pow(10,C-m*Cycles)
# N.append(nvalue)
#	print N
	N=[]
	x=1
	for x in range(1,len(stressrange)):
		logval=math.log(stressrange[x],10)-3
		nvalue=math.pow(10,C-m*logval)
		x+=1
		N.append(nvalue)
	N.insert(0,0)
	D=[]
	i=1
	for i in range(1,len(pressure_range)):
		damge=Sum_w[i]/N[i]
		i+=1
		D.append(damge)
	D.insert(0,0)
	CumD=[]
	Sum=0
	for i in range(1,len(D)):
		Sum=Sum+D[i]
		CumD.append(Sum)
	CumD.insert(0,0)
	print CumD
	cumulative_damage=CumD[-1]
	str_level=13000
	SMYS=pyds3[2][1]
	SSI=cumulative_damage*math.pow(10,C-m*(math.log(str_level,10)-m))
	SSI_stresspercent=str_level/SMYS*100
	remaining_life=1/(cumulative_damage/(max(Load_Array)/(356*1440)))
	pro_of_failure=1-math.pow(math.e,(-1)*math.pow(5*cumulative_damage,2.5))
	print SSI
	print SSI_stresspercent
	print remaining_life
	print pro_of_failure
	print cumulative_damage
	headers=["SSI","SSI%","remaining_life","stresslevel","pro_of_failure","cumulativedamge"]
	data=[]
	data.append([SSI,SSI_stresspercent,remaining_life,str_level,pro_of_failure,cumulative_damage])
	system.tag.writeBlocking("[default]pressure",system.dataset.toDataset(headers,data),pressure)
#	pressurecycles=[]
#	i=0
#	for i in range(0,len(pressure_range)):
# pressurecycles.append([pressure_range[i],Sum_w[i],stressrange[i],N[i],D[i],CumD[i]])
#	system.tag.writeBlocking("[default]pressurecycles",system.dataset.toDataSet(['P','n','stressrange','N','D','CumD'],pressurecycles))

```

---

<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:** [October 19, 2021, 1:49am UTC](https://forum.inductiveautomation.com/t/how-to-fix-attributeerror-com-inductiveautomation-ignition-designer-gui-tool-object-has-no-attribute-todataset/52084/2 "2021-10-19T01:49:28Z")

</div>

The function is `system.dataset.toDataSet`

notice the Capital S, you don’t want to know how many times I’ve seen that fault. Remember that case sensitivity is a thing in jython/python.

---

<div class="post-metadata">

**Author:** ![jill.zhao](https://avatars.discourse-cdn.com/v4/letter/j/4bbf92/32.png) [@jill.zhao](https://forum.inductiveautomation.com/u/jill.zhao)\
**Post date:** [October 19, 2021, 2:39pm UTC](https://forum.inductiveautomation.com/t/how-to-fix-attributeerror-com-inductiveautomation-ignition-designer-gui-tool-object-has-no-attribute-todataset/52084/3 "2021-10-19T14:39:35Z")

</div>

Thank you, after I change the Captial S. I still get the error,IndexError: Row 0 doesn’t have the same number of columns as header list.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [October 19, 2021, 2:43pm UTC](https://forum.inductiveautomation.com/t/how-to-fix-attributeerror-com-inductiveautomation-ignition-designer-gui-tool-object-has-no-attribute-todataset/52084/4 "2021-10-19T14:43:35Z")

</div>

Can you post the full error?

Even without it I can tell you something is wrong with your `system.tag.writeBlocking` code because the first 2 arguments should be lists and if you use a 3rd argument it’s only for a timeout value.

---

<div class="post-metadata">

**Author:** ![jill.zhao](https://avatars.discourse-cdn.com/v4/letter/j/4bbf92/32.png) [@jill.zhao](https://forum.inductiveautomation.com/u/jill.zhao)\
**Post date:** [October 19, 2021, 2:44pm UTC](https://forum.inductiveautomation.com/t/how-to-fix-attributeerror-com-inductiveautomation-ignition-designer-gui-tool-object-has-no-attribute-todataset/52084/5 "2021-10-19T14:44:34Z")

</div>

> > > waterfall.handler3.finaloutput()  
> > > 25.9965292099  
> > > 37.1428571429  
> > > 18232.6622794  
> > > 2.67019739653e-12  
> > > 4.69510438502e-06  
> > > Traceback (most recent call last):  
> > > File "", line 1, in   
> > > File "module:waterfall.handler3", line 94, in finaloutput  
> > > IndexError: Row 0 doesn't have the same number of columns as header list.

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [October 19, 2021, 2:49pm UTC](https://forum.inductiveautomation.com/t/how-to-fix-attributeerror-com-inductiveautomation-ignition-designer-gui-tool-object-has-no-attribute-todataset/52084/6 "2021-10-19T14:49:06Z")

</div>

What line is line 94?

---

<div class="post-metadata">

**Author:** ![jill.zhao](https://avatars.discourse-cdn.com/v4/letter/j/4bbf92/32.png) [@jill.zhao](https://forum.inductiveautomation.com/u/jill.zhao)\
**Post date:** [October 19, 2021, 2:50pm UTC](https://forum.inductiveautomation.com/t/how-to-fix-attributeerror-com-inductiveautomation-ignition-designer-gui-tool-object-has-no-attribute-todataset/52084/7 "2021-10-19T14:50:10Z")

</div>

```
system.tag.writeBlocking("[default]pressure",system.dataset.toDataSet([headers,data],pressure))
```

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [October 19, 2021, 2:52pm UTC](https://forum.inductiveautomation.com/t/how-to-fix-attributeerror-com-inductiveautomation-ignition-designer-gui-tool-object-has-no-attribute-todataset/52084/8 "2021-10-19T14:52:05Z")

</div>

Ok, well what @Kevin.Herron said. You’re trying to write a dataset to a pressure tag, that seems wrong, and you’re passing a variable called ‘pressure’ as the write time out. That also seems wrong

Oh wait, you changed it. But it still looks wrong, as now you’ve moved the pressure inside of the to dataset function

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [October 19, 2021, 2:53pm UTC](https://forum.inductiveautomation.com/t/how-to-fix-attributeerror-com-inductiveautomation-ignition-designer-gui-tool-object-has-no-attribute-todataset/52084/9 "2021-10-19T14:53:30Z")

</div>

Both your method calls are wrong here ☹

Try this, broken out for clarity:

```auto
ds = system.dataset.toDataSet(headers,data)
system.tag.writeBlocking("[default]pressure", ds)

```

Except I have no idea what you were trying to do with the pressure variable.

Based on the tag name maybe you just want to write the pressure variable to the pressure tag, but then I don’t know what you’re doing with the DataSet.

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [October 19, 2021, 2:56pm UTC](https://forum.inductiveautomation.com/t/how-to-fix-attributeerror-com-inductiveautomation-ignition-designer-gui-tool-object-has-no-attribute-todataset/52084/10 "2021-10-19T14:56:56Z")

</div>

I can’t even see where that pressure variable is defined in your code, unless it’s only a snippet?

---

<div class="post-metadata">

**Author:** ![jill.zhao](https://avatars.discourse-cdn.com/v4/letter/j/4bbf92/32.png) [@jill.zhao](https://forum.inductiveautomation.com/u/jill.zhao)\
**Post date:** [October 19, 2021, 2:57pm UTC](https://forum.inductiveautomation.com/t/how-to-fix-attributeerror-com-inductiveautomation-ignition-designer-gui-tool-object-has-no-attribute-todataset/52084/11 "2021-10-19T14:57:49Z")

</div>

after trying this

```auto
pressure=[]
	headers=["SSI","SSI%","remaining_life","stresslevel","pro_of_failure","cumulativedamge"]
	data=pressure.append([SSI,SSI_stresspercent,remaining_life,str_level,pro_of_failure,cumulative_damage])
	ds = system.dataset.toDataSet(headers,data)
	system.tag.writeBlocking("[default]pressure", ds)

```

I get the new error:Java Traceback:  
Traceback (most recent call last):  
File “”, line 1, in   
File “module:waterfall.handler3”, line 94, in finaloutput  
at com.inductiveautomation.ignition.common.script.builtin.DatasetUtilities.toDataSet(DatasetUtilities.java:516)

```
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.base/java.lang.reflect.Method.invoke(Unknown Source)

```

java.lang.NullPointerException: java.lang.NullPointerException

---

<div class="post-metadata">

**Author:** ![jill.zhao](https://avatars.discourse-cdn.com/v4/letter/j/4bbf92/32.png) [@jill.zhao](https://forum.inductiveautomation.com/u/jill.zhao)\
**Post date:** [October 19, 2021, 2:59pm UTC](https://forum.inductiveautomation.com/t/how-to-fix-attributeerror-com-inductiveautomation-ignition-designer-gui-tool-object-has-no-attribute-todataset/52084/12 "2021-10-19T14:59:48Z")

</div>

The output pressure tag should made from several numbers which is SSI,SSI% I have print it out, I want them get a tag in ignition. thanks

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [October 19, 2021, 3:02pm UTC](https://forum.inductiveautomation.com/t/how-to-fix-attributeerror-com-inductiveautomation-ignition-designer-gui-tool-object-has-no-attribute-todataset/52084/13 "2021-10-19T15:02:26Z")

</div>

You shouldnt be assigning data to the result of that append. Append doesn’t return the list, it mutates the list itself. You need to do this in two steps.  
pressure.append([…])  
data=pressure

---

<div class="post-metadata">

**Author:** ![jill.zhao](https://avatars.discourse-cdn.com/v4/letter/j/4bbf92/32.png) [@jill.zhao](https://forum.inductiveautomation.com/u/jill.zhao)\
**Post date:** [October 19, 2021, 3:10pm UTC](https://forum.inductiveautomation.com/t/how-to-fix-attributeerror-com-inductiveautomation-ignition-designer-gui-tool-object-has-no-attribute-todataset/52084/14 "2021-10-19T15:10:50Z")

</div>

```auto
pressure=[]
	headers=["SSI","SSI%","remaining_life","stresslevel","pro_of_failure","cumulativedamge"]
	pressure.append([SSI,SSI_stresspercent,remaining_life,str_level,pro_of_failure,cumulative_damage])
	data=pressure
	ds = system.dataset.toDataSet(headers,data)
	system.tag.writeBlocking("[default]pressure", ds)

```

Thank you so much, I get the tag.
