# Column index 'x' out of range

**URL:** <https://forum.inductiveautomation.com/t/column-index-x-out-of-range/10519>\
**Category:** Ignition\
**Created:** [September 25, 2015, 1:03pm UTC](https://forum.inductiveautomation.com/t/column-index-x-out-of-range/10519 "2015-09-25T13:03:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![the\_newb](https://avatars.discourse-cdn.com/v4/letter/t/9de0a6/32.png) [@the\_newb](https://forum.inductiveautomation.com/u/the_newb)\
**Post date:** [September 25, 2015, 1:03pm UTC](https://forum.inductiveautomation.com/t/column-index-x-out-of-range/10519/1 "2015-09-25T13:03:08Z")

</div>

I am running a script looking at a dataset,  
The code in question is this…

if labelName == ‘DEFECT LABEL 3’:  
return pyData[0][0]  
if labelName == ‘DEFECT LABEL 4’:  
return pyData[1][0]  
if labelName == ‘DEFECT LABEL 5’:  
return pyData[2][0]

it works great, but sometimes my data set won’t have as many rows as I have if statements.  
How can I say -  
if pyData[1][0] is out of range:  
return ‘NA’  
else:  
return pyData[1][0]

Thank you…

---

<div class="post-metadata">

**Author:** ![diat150](https://avatars.discourse-cdn.com/v4/letter/d/a587f6/32.png) [@diat150](https://forum.inductiveautomation.com/u/diat150)\
**Post date:** [September 25, 2015, 1:36pm UTC](https://forum.inductiveautomation.com/t/column-index-x-out-of-range/10519/2 "2015-09-25T13:36:15Z")

</div>

you could check the length of your dataset first. then in each if statement, first check to make sure that the row you are asking for is within the range of the dataset.

---

<div class="post-metadata">

**Author:** ![the\_newb](https://avatars.discourse-cdn.com/v4/letter/t/9de0a6/32.png) [@the\_newb](https://forum.inductiveautomation.com/u/the_newb)\
**Post date:** [September 25, 2015, 1:48pm UTC](https://forum.inductiveautomation.com/t/column-index-x-out-of-range/10519/3 "2015-09-25T13:48:55Z")

</div>

Awesome, works perfect. Thank you!
