Get the first and second row with searchcursor

المشرف العام

Administrator
طاقم الإدارة
I have a shapefile with only 4 rows in it. I already could filter it so I have only 2 left. I need these sorted by the 'length' field, then take the first and second row to save in to individual files. Here is the code for sorting:

import arcpy fc = 'C:\\Users\\test.shp' fields = ['length', 'FID'] expression = arcpy.AddFieldDelimiters(fc, "length") + " > 1000" for row in sorted(arcpy.da.SearchCursor(fc, fields,)): print('{0}, {1}'.format(row[0], row[1])) For saving in to the new file:

arcpy.FeatureClassToFeatureClass_conversion(?, outLocation, outFeatureClass,) How can I make the search cursor to show first only the lower value row, then the higher one? (order doesn't matter)

Update: So make it the question clear: How can I select the number 1 row, then the number 2 row?



أكثر...
 
أعلى