# Find Data in PyDataset

**URL:** <https://forum.inductiveautomation.com/t/find-data-in-pydataset/10472>\
**Category:** Ignition\
**Created:** [September 15, 2015, 9:34pm UTC](https://forum.inductiveautomation.com/t/find-data-in-pydataset/10472 "2015-09-15T21:34:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jreynolds](https://avatars.discourse-cdn.com/v4/letter/j/58956e/32.png) [@jreynolds](https://forum.inductiveautomation.com/u/jreynolds)\
**Post date:** [September 15, 2015, 9:34pm UTC](https://forum.inductiveautomation.com/t/find-data-in-pydataset/10472/1 "2015-09-15T21:34:06Z")

</div>

I’m trying to access a PyDataset and I can return the records in the first row but can’t seem to find the records in the second row. Currently the dataset has only 2 rows but will get to about 40.

[code]data = event.source.parent.partsTable  
pds = system.dataset.toPyDataSet(data)  
next = 1  
stringNull = “”  
event.source.parent.PT.PartInfo.PN.STR = “p”  
event.source.parent.PT.PartInfo.QTY.STR = “q”  
resetButton = event.source.parent.getComponent(‘butReset’)  
currentCycleTime = event.source.parent.getComponent(‘numCurrentCycleTime’).floatValue  
foundFlag = 0  
error = 0

```
if scanEntry == "":
	error = 9
#Enables the Operator to Reset the Cycle using the Barcode Gun.	
elif scanEntry == "4565":
	error = 1
	resetButton.doClick
elif processStep == 0:
#Parses the Part Number
	pn = scanEntry.lstrip('event.source.parent.PT.PartInfo.PN.STR')
	event.source.parent.PT.PartInfo.PN.Value = pn
	from java.util import Date
	event.source.parent.PT.StartTime = Date()		
elif processStep == 1:
#Parses the Quantity
	for row in pds:
		if row['part_num'] == event.source.parent.PT.PartInfo.PN.Value:
			pnChk=row["part_num"]
			foundFlag = 1
		if foundFlag == 0:
			error = 5
		else:
			qty = scanEntry.lstrip('q')
			event.source.parent.PT.PartInfo.QTY.Value = qty[/code]

```

This code works to find the first row but won’t find the second.

---

<div class="post-metadata">

**Author:** ![JGJohnson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jgjohnson/32/29582_2.png) [@JGJohnson](https://forum.inductiveautomation.com/u/JGJohnson)\
**Post date:** [September 15, 2015, 10:26pm UTC](https://forum.inductiveautomation.com/t/find-data-in-pydataset/10472/2 "2015-09-15T22:26:10Z")

</div>

The script looks like it should work just fine. How are you determining that it is not reading the 2nd row?

Maybe this is a stupid question but is the value for part\_num the same in both rows?

---

<div class="post-metadata">

**Author:** ![AlThePal](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/althepal/32/3603_2.png) [@AlThePal](https://forum.inductiveautomation.com/u/AlThePal)\
**Post date:** [September 16, 2015, 7:38am UTC](https://forum.inductiveautomation.com/t/find-data-in-pydataset/10472/3 "2015-09-16T07:38:58Z")

</div>

The last part of your script seems a bit redundant the way it is written. Should the part from ‘if foundFlag == 0’ be outside the ‘for row in pds’ loop?
