Select to view content in your preferred language

Field Indexing, arcpy.SearchCursor

767
1
08-28-2013 12:40 PM
MikeMacRae
Frequent Contributor
Does the arcpy.SearchCursor function support field indexing? In the sample script below, can I sent my cursor to loop through the values in the first field by setting an index to search the first field?

for x in arcpy.SearchCursor(filepath):
    print x[0]
Tags (2)
0 Kudos
1 Reply
DaveBarrett
Deactivated User
Hi,

Do not believe it is possibly with the old style search cursor. It is def possible in 10.1 with the data access module cursors. These also perform a lot faster.

arcpy.da.SearchCursor(FC,fields)

The fields value is a python lists of fields.

Here is the help for it
http://resources.arcgis.com/en/help/main/10.1/index.html#/SearchCursor/018w00000011000000

At 10 and before you have to use row.getValue(field)
http://resources.arcgis.com/en/help/main/10.1/index.html#//018v00000050000000

Hope this helps


Dave
0 Kudos