# Search a table for a specific value

**URL:** <https://forum.inductiveautomation.com/t/search-a-table-for-a-specific-value/4436>\
**Category:** General Discussion\
**Created:** [May 9, 2012, 3:42pm UTC](https://forum.inductiveautomation.com/t/search-a-table-for-a-specific-value/4436 "2012-05-09T15:42:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Duffanator](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/duffanator/32/3560_2.png) [@Duffanator](https://forum.inductiveautomation.com/u/Duffanator)\
**Post date:** [May 9, 2012, 3:42pm UTC](https://forum.inductiveautomation.com/t/search-a-table-for-a-specific-value/4436/1 "2012-05-09T15:42:53Z")

</div>

Hey guys,

Just thought I’d post this since it took me a while to figure out, thought it may come in useful for someone else.

Here is a script I wrote on a button to search through data in a table and automatically select that row. The find variable is from a numeric entry box (but could easily be a text box or drop down or whatever), the index in the function is what column to search through (0 is the first column, 1 the second, etc…).

[code]table = event.source.parent.getComponent(‘Table’)  
data = system.dataset.toPyDataSet(table.data)  
find = event.source.parent.getComponent(‘Numeric Text Field 1’).intValue

def getIndexOfTuple(l, index, value):  
import system.gui  
for pos,t in enumerate(l):  
if t[index] == value:  
return pos

```
system.gui.errorBox("Sequence Number not found in selected data!","Sequence Number Not Found")

```

ndx = getIndexOfTuple(data, 1, find)  
if ndx != None:  
event.source.parent.getComponent(‘Table’).selectedRow = ndx[/code]

---

<div class="post-metadata">

**Author:** ![Duffanator](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/duffanator/32/3560_2.png) [@Duffanator](https://forum.inductiveautomation.com/u/Duffanator)\
**Post date:** [August 27, 2014, 1:22pm UTC](https://forum.inductiveautomation.com/t/search-a-table-for-a-specific-value/4436/2 "2014-08-27T13:22:16Z")

</div>

Not in Python…
