# How to fix TypeError: Unable to convert row 1, column 3 to type class java.lang.Integer

**URL:** <https://forum.inductiveautomation.com/t/how-to-fix-typeerror-unable-to-convert-row-1-column-3-to-type-class-java-lang-integer/52186>\
**Category:** Ignition\
**Tags:** ignition81, database, scripting\
**Created:** [October 20, 2021, 8:46pm UTC](https://forum.inductiveautomation.com/t/how-to-fix-typeerror-unable-to-convert-row-1-column-3-to-type-class-java-lang-integer/52186 "2021-10-20T20:46:48Z")\
**Posts on this page:** 4\
**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 20, 2021, 8:46pm UTC](https://forum.inductiveautomation.com/t/how-to-fix-typeerror-unable-to-convert-row-1-column-3-to-type-class-java-lang-integer/52186/1 "2021-10-20T20:46:48Z")

</div>

Hi I write the function to create a tag , I have test the script, I have successful get two output, but when I try the third input, it said :

```auto
  File "<input>", line 1, in <module>
  File "<module:waterfall.handler2>", line 106, in rainflow_calc
TypeError: Unable to convert row 1, column 3 to type class java.lang.Integer
could you please help to fix it? thanks

outputfeb1=[]
for i in range(len(LocalCycles1)):
     outputfeb1.append([i+1,LocalCycles1[i],LocalCycles2[i],LocalCycles3[i]])
system.tag.writeBlocking("[default]outputfeb1", system.dataset.toDataSet(['Index','Range','Mean','Cycles'],outputfeb1))	

```

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [October 20, 2021, 8:59pm UTC](https://forum.inductiveautomation.com/t/how-to-fix-typeerror-unable-to-convert-row-1-column-3-to-type-class-java-lang-integer/52186/2 "2021-10-20T20:59:50Z")

</div>

Without insight into what that value actually is, your help will be limited. I’ve seen similar issues when casting strings to integers, but your issue looks to be coming from the `toDataSet` function. I suspect a value in `outputFeb1` is being assigned to an int column (Cycles) but is not something which can be cast as an int.

---

<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 20, 2021, 9:06pm UTC](https://forum.inductiveautomation.com/t/how-to-fix-typeerror-unable-to-convert-row-1-column-3-to-type-class-java-lang-integer/52186/3 "2021-10-20T21:06:30Z")

</div>

```auto
def rainflow_calc():
	print("Starting RainFlow Calculation")
	
	dataset = system.tag.read("[default]outputfeb").value
	
	number_of_loads = dataset.getRowCount()
	
	pyds =system.dataset.toPyDataSet(dataset)
	My_list=[]
	for column in pyds:
	    load=column[0]
	    My_list.append(load) 
	Index=range(1,number_of_loads)
#	for column in pyds:
# index=column[0]
# Index.append(index)
	LocalCycles1=[]
	LocalCycles2=[]
	LocalCycles3=[]
	Isactive=[True] * number_of_loads 
	StartIndex = 0
	counter= 1
	Index[0]=0
	Index[1]=1
	rangeprevious=abs(My_list[1]-My_list[0])
	for J in range(2,number_of_loads):
		Index[2]=J
		rangecurrent=abs(My_list[Index[2]]-My_list[Index[1]])
		if rangecurrent<rangeprevious:
			Index[0]=Index[1]
			Index[1]=Index[2]
			rangeprevious=rangecurrent
		elif Index[0]==StartIndex:
			LocalCycles1.append(rangeprevious)
			LocalCycles2.append((My_list[Index[0]]+My_list[Index[1]])/2)
			LocalCycles3.append(0.5)
			Isactive[Index[0]]=False
			counter=counter+1
			StartIndex=Index[1]
			Index[0]=Index[1]
			Index[1]=Index[2]
			rangeprevious=rangecurrent
		else:
			LocalCycles1.append(rangeprevious)
			LocalCycles2.append((My_list[Index[0]]+My_list[Index[1]])/2)
			LocalCycles3.append(1)
			Isactive[Index[0]]=False
			Isactive[Index[1]]=False
			counter=counter+1
			Index[1]=NextLowest_Index(Index[2], Isactive)
			if Index[1]==StartIndex:
				Index[0]=Index[1]
				Index[1]=Index[2]
				rangeprevious=abs(My_list[Index[1]]-My_list[Index[0]])
			else:
				Index[0]=NextLowest_Index(Index[1],Isactive)
				Done=False
				while Done==False:
					rangeprevious=abs(My_list[Index[1]]-My_list[Index[0]])
					rangecurrent=abs(My_list[Index[2]]-My_list[Index[1]])
					if rangecurrent< rangeprevious:
						Index[0]=Index[1]
						Index[1]=Index[2]
						rangeprevious=rangecurrent
						Done=True
					elif Index[0]==StartIndex:
						LocalCycles1.append(rangeprevious)
						LocalCycles2.append((My_list[Index[0]]+My_list[Index[1]])/2)
						LocalCycles3.append(0.5)
						Isactive[Index[0]]=False
						counter=counter+1
						StartIndex=Index[1]
						Index[0]=Index[1]
						Index[1]=Index[2]
						rangeprevious=rangecurrent
						Done=True
				 	else:
				 		LocalCycles1.append(rangeprevious)
				 		LocalCycles2.append((My_list[Index[0]]+My_list[Index[1]])/2)
				 		LocalCycles3.append(1)
						Isactive[Index[0]]=False
						Isactive[Index[1]]=False
						counter=counter+1
						Index[1]=NextLowest_Index(Index[2], Isactive)
						if Index[1]==StartIndex:
							Index[0]=Index[1]
							Index[1]=Index[2]
							rangeprevious=abs(My_list[Index[1]]-My_list[Index[0]])
							Done =True
						else:
							Index[0]=NextLowest_Index(Index[1], Isactive)
	if StartIndex<J:
		Index[0]=StartIndex
		Index[1]=NextHighest_Index(Index[0], Isactive)
		Done=False
		while Done==False:
			LocalCycles1.append(abs(My_list[Index[1]]-My_list[Index[0]]))	
			LocalCycles2.append((My_list[Index[0]]+My_list[Index[1]])/2)
			LocalCycles3.append(0.5)
			if Index[1]==number_of_loads-1:
				Done=True
			else:
				Index[0]=Index[1]
				Index[1]=NextHighest_Index(Index[0], Isactive)
				counter=counter+1
				
	outputfeb1=[]
	for i in range(len(LocalCycles1)):
		outputfeb1.append([i+1,LocalCycles1[i],LocalCycles2[i],LocalCycles3[i]])
	system.tag.writeBlocking("[default]outputfeb1", system.dataset.toDataSet(['Index','Range','Mean','Cycles'],outputfeb1))		

def NextLowest_Index(I,Isactive):
	Done=False
	J=I-1
	while Done==False:
		if Isactive[J]==True:
			Done=True
		else:
			J=J-1
	returnval=J
	return returnval
	
def NextHighest_Index(I, Isactive):
	Done=False
	J=I+1
	while Done==False:
		if Isactive[J]==True:
			Done=True
		else:
			J=J+1
	returnval=J
	return returnval
	

```

that is my script, I could not figure out, thanks

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [October 21, 2021, 8:13am UTC](https://forum.inductiveautomation.com/t/how-to-fix-typeerror-unable-to-convert-row-1-column-3-to-type-class-java-lang-integer/52186/4 "2021-10-21T08:13:52Z")

</div>

> [@jill.zhao](#):
>
> `LocalCycles3.append(0.5)`

it seems you are passing a double to an integer column

change the integer columns in [default]outputfeb1 to double
