# Comparing user input with a PyDataSet

**URL:** <https://forum.inductiveautomation.com/t/comparing-user-input-with-a-pydataset/12302>\
**Category:** Ignition\
**Created:** [October 28, 2016, 4:51pm UTC](https://forum.inductiveautomation.com/t/comparing-user-input-with-a-pydataset/12302 "2016-10-28T16:51:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![pollux](https://avatars.discourse-cdn.com/v4/letter/p/53a042/32.png) [@pollux](https://forum.inductiveautomation.com/u/pollux)\
**Post date:** [October 28, 2016, 4:51pm UTC](https://forum.inductiveautomation.com/t/comparing-user-input-with-a-pydataset/12302/1 "2016-10-28T16:51:52Z")

</div>

Greetings all. First time poster; and new to Jython user. I hope this is the section for this question.  
I have a PyDataSet. I want to see if any entry in the first column matches an input from the user. Here’s my situation: we are installing a kiosk with a touch screen at our fresh fruit receiving area. A truck driver will input his/her truck load number. This goes into a client integer called [Client]LN. I need to scan the first column in the PyDataSet to see if any load number in that column matches the driver’s input. The name of the first column is “load\_number”.

Any ideas?

---

<div class="post-metadata">

**Author:** ![TedNewman](https://avatars.discourse-cdn.com/v4/letter/t/85e7bf/32.png) [@TedNewman](https://forum.inductiveautomation.com/u/TedNewman)\
**Post date:** [October 28, 2016, 5:00pm UTC](https://forum.inductiveautomation.com/t/comparing-user-input-with-a-pydataset/12302/2 "2016-10-28T17:00:53Z")

</div>

A simple and fairly easy to read solution would be something like this:

[code]clientLN = system.tag.read(“PATH/TO/TAG/[Client]LN”).value  
myDataSet = PUT\_PY\_DATA\_SET\_HERE  
match = False  
for row in myDataSet:  
if row[“load\_number”] == clientLN:  
match = True  
break

if match:  
doMoreCodeHere()  
[/code]

---

<div class="post-metadata">

**Author:** ![pollux](https://avatars.discourse-cdn.com/v4/letter/p/53a042/32.png) [@pollux](https://forum.inductiveautomation.com/u/pollux)\
**Post date:** [October 28, 2016, 5:51pm UTC](https://forum.inductiveautomation.com/t/comparing-user-input-with-a-pydataset/12302/3 "2016-10-28T17:51:22Z")

</div>

Thanks Ted!

I can see how the logic should work. However it fails on two counts (I think 😮 ):  
When I convert from a database dataset to a pydataset, I think I lose my column names, so “load\_number” is not recognized by the interpreter. So I removed the column name thus:

clientLN = system.tag.read("[Client]LN").value  
myDataSet = pds  
match = False  
for row in myDataSet:  
if row == clientLN:  
match = True  
break

print(match)  
print(clientLN)  
print(myDataSet)

My output on the output screen reads:

False  
86833

I do know one of the load numbers is 86833 so my output should be true. I can’t figure out why it is false. ![:scratch:](https://us1.discourse-cdn.com/inductiveautomation/original/1X/76d1620bec252bfac07050c889ff5a91dc8a9c25.gif ":scratch:")

---

<div class="post-metadata">

**Author:** ![TedNewman](https://avatars.discourse-cdn.com/v4/letter/t/85e7bf/32.png) [@TedNewman](https://forum.inductiveautomation.com/u/TedNewman)\
**Post date:** [October 28, 2016, 10:13pm UTC](https://forum.inductiveautomation.com/t/comparing-user-input-with-a-pydataset/12302/4 "2016-10-28T22:13:59Z")

</div>

Your pyDataSet should not be losing column names so there should be no issue referencing by column name as I did. Additionally, in your code segment you are comparing the entire row to a numerical value with [tt]if row == clientLN:[/tt] so they’re not going to match at any point.
