# Dataset Turning into Int Inside For Loop

**URL:** <https://forum.inductiveautomation.com/t/dataset-turning-into-int-inside-for-loop/66482>\
**Category:** Ignition\
**Tags:** ignition81, scripting, perspective\
**Created:** [November 14, 2022, 4:58pm UTC](https://forum.inductiveautomation.com/t/dataset-turning-into-int-inside-for-loop/66482 "2022-11-14T16:58:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Isaac\_Hodgkins](https://avatars.discourse-cdn.com/v4/letter/i/59ef9b/32.png) [@Isaac\_Hodgkins](https://forum.inductiveautomation.com/u/Isaac_Hodgkins)\
**Post date:** [November 14, 2022, 4:58pm UTC](https://forum.inductiveautomation.com/t/dataset-turning-into-int-inside-for-loop/66482/1 "2022-11-14T16:58:51Z")

</div>

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/b/7b6cd261dc29a617475d5f48e6c292a03295ee9a.png)

```auto
type or def runAction(self, event):
	"""
	This event is fired when the 'action' of the component occurs.

	Arguments:
		self: A reference to the component that is invoking this function.
		event: An empty event object.
	"""
	#loop through dataset and send to sql
	
	#get dataSet parameters
	dataSet = self.parent.parent.parent.getChild("Table").props.data
	rowCount = dataSet.getRowCount()
	modIndex = dataSet.getColumnIndex("modified")
	#get edited value indexes
	ignition_g_kpi_ndxIndex = dataSet.getColumnIndex("ignition_g_kpi_ndx")
	unitNumberIndex = dataSet.getColumnIndex("unitNumber")
	orderNumberIndex = dataSet.getColumnIndex("orderNumber")
	shiftIndex = dataSet.getColumnIndex("ShiftName")
	validIndex = dataSet.getColumnIndex("valid")
	commentsIndex = dataSet.getColumnIndex("comments")
	#loop through dataset and change any rows that have been modified
	self.parent.parent.parent.getChild("FlexContainer_0").getChild("Label").props.text = dataSet#test1
	for row in range(rowCount):
		dataSet = self.parent.parent.parent.getChild("Table").props.data
		self.parent.parent.parent.getChild("FlexContainer_0").getChild("Label_0").props.text = dataSet#test2
		modified = dataSet.getValueAt(row, modIndex)
		if modified == 1:
			ignition_g_kpi_ndx = dataSet.getValueAt(row, ignition_g_kpi_ndxIndex)
			unitNumber = dataSet.getValueAt(row, unitNumberIndex)
			orderNumber = dataSet.getValueAt(row, orderNumberIndex)
			shift = dataSet.getValueAt(row, shiftIndex)
			valid = dataSet.getValueAt(row, validIndex)
			comments = dataSet.getValueAt(row, commentsIndex)
			dataSetOrderNumber = self.view.params.data[0]['Order Number']
			#run named query to update dataset and return updated dataset
			namedQuery = "ignition_g_kpi Update"
			parameters = {"ignition_g_kpi_ndx":ignition_g_kpi_ndx, "unitNumberIndex":unitNumberIndex, "orderNumber":orderNumber, "shift":shift, "valid":valid, "comments":comments, "dataSetOrderNumber":dataSetOrderNumber} 
			dataSet = system.db.runNamedQuery(namedQuery, parameters)
			self.view.params.data[0]['Order Number']
			#set dataset props to new dataset
			self.parent.parent.parent.getChild("Table").props.data = dataSet
			self.parent.parent.parent.getChild("Table").custom.backUpData
	#turn edit mode off
	self.view.params.edit = False

```

I've been trying to loop through a dataset to get the values at different rows.  
I'm getting an error that I can't use getValueAt on an Int because it's not an attribute.

I then looked to see what's happening to my dataset and read it before and after the for loop and printed it to a label. Before the for loop I get my dataset, after the for loop it's turning into the int "1"  
This happens even if I re define the dataset inside the for loop.

Any help would be appreciated, thanks!

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [November 14, 2022, 5:28pm UTC](https://forum.inductiveautomation.com/t/dataset-turning-into-int-inside-for-loop/66482/2 "2022-11-14T17:28:40Z")

</div>

You are using the `dataSet` variable for multiple purposes. Use different names for each purpose.
