lundi 23 février 2015

SearchCursor Index Out of Range


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.





Aucun commentaire:

Enregistrer un commentaire