curs = arcpy.SearchCursor(table) for row in curs: listing.append(row.min_value) print min((abs(0 - i), i) for i in listing)[1]
Looks good, much more fleshed out. Maybe I am missing something though, this doesn't seem to preserve the negative sign with the xmin assignment.
Matt - I guess I have a tweak: tv = arcpy.MakeTableView(table) curs = arcpy.SearchCursor(tv) listing = list() # create a list for row in curs: listing.append(row.min_value) del row, curs # always a good idea when done! xmin = min([abs(i) for i in listing]) # now get that record (or the first if several) with that abs value curs = SearchCursor(tv,"abs(%s) = %s" % (min_value,xmin)) # get the value for field "shapefile" shapefile = curs.next().shapefile del curs
tv = arcpy.MakeTableView(table) curs = arcpy.SearchCursor(tv) listing = list() # create a list for row in curs: listing.append(row.min_value) del row, curs # always a good idea when done! xmin = min([abs(i) for i in listing]) # now get that record (or the first if several) with that abs value curs = SearchCursor(tv,"abs(%s) = %s" % (min_value,xmin)) # get the value for field "shapefile" shapefile = curs.next().shapefile del curs
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.