[GIS] SearchCursor Index Out of Range

arcgis-10.2arcpycursorpython

I'm using ArcGIS 10.2 and trying to obtain values in a field using SearchCursor. Would someone help me with this?

import arcpy

oc = r"C:\Users\Scratch\oc.shp"

catchments = arcpy.da.SearchCursor(oc,"FEATUREID")

catchment = catchments.next()

for catchment in catchments:

   print catchment[0]

   print catchment[1] 

catchments.reset()

The catchment[0] works, but if I try anything higher, I get tuple out of range error.
There are 11 rows in the shapefile, all with a unique FEATUREID. I can only extract either the 1st row or all of them at once. I need to be able to specify througout the rest of my code when I want the 1st, 2nd, 3rd, or 10th value in this shapefile under field = FEATUREID.

Best Answer

The search cursor second parameter is the field name list. You are only providing one field name that is why it is not going beyond index 0.

A list (or tuple) of field names. For a single field, you can use a string instead of a list of strings.

Try:

catchmentFields = ["FEATUREID", "field2", "field3"]
catchments = arcpy.da.SearchCursor(oc, catchmentFields)