Quantcast
Channel: Question and Answer » arcpy
Viewing all articles
Browse latest Browse all 767

SearchCursor Index Out of Range

$
0
0

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:UsersScratchoc.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.


Viewing all articles
Browse latest Browse all 767

Trending Articles