Solved! Go to Solution.
curs = arcpy.SearchCursor(table) for row in curs: listing.append(row.min_value) print min((abs(0 - i), i) for i in listing)[1]
curs = arcpy.SearchCursor(table) for row in curs: listing.append(row.min_value) print min((abs(0 - i), i) for i in listing)[1]
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
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
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.