import arcpy # Open a searchcursor # Input: C:/Data/Counties.shp # Fields: NAME; STATE_NAME; POP2000 # Sort fields: STATE_NAME A; POP2000 D rows = arcpy.SearchCursor("c:/data/counties.shp", fields="NAME; STATE_NAME; POP2000", sort_fields="STATE_NAME A; POP2000 D") # Iterate through the rows in the cursor and print out the # state name, county and population of each. for row in rows: print("State: {0}, County: {1}, Population: {2}".format( row.getValue("STATE_NAME"), row.getValue("NAME"), row.getValue("POP2000")))
Solved! Go to Solution.