How Can I Find The Missing Sequence Number in a Field in ArcGIS I have thousand numbers on that field ? I have ArcGIS 10.8
You can do it with a little Python script:
fc = "TestPolygons" # path the the feature class or name of the layer field = "IntegerField1" # get a set of values in the field values = {row[0] for row in arcpy.da.SearchCursor(fc, [field])} # get a set of the complete range complete_values = set(range(min(values), max(values))) # the difference between these sets are the missing numbers missing_values = complete_values - values print(sorted(missing_values))
fc = "TestPolygons" # path the the feature class or name of the layer field = "IntegerField1" group_field = "TextField1" # read the fc data = [row for row in arcpy.da.SearchCursor(fc, [group_field, field])] # iterate over the groups groups = {d[0] for d in data} for g in sorted(groups): # get the values in that group values = {d[1] for d in data if d[0] == g} # get a set of the complete range complete_values = set(range(min(values), max(values))) # the difference between these sets are the missing numbers missing_values = complete_values - values print("Missing values in group {}: {}".format(g, sorted(missing_values)))
what should I change in your Python script to work , I create field test to run your Python script but it does not work , I want to know the missing number in field parcel ….I need more details!!!
The script is meant to be run in the Python Window, not in the Fieled Calculator.
Hello i am receiving this error message when trying to run.
fc = r"path"field = "FXSA_ID"
# get a set of values in the fieldvalues = {row[0] for row in arcpy.da.SearchCursor(fc, [field])}# get a set of the complete rangecomplete_values = set(range(min(values), max(values)))# the difference between these sets are the missing numbersmissing_values = complete_values - valuesprint(sorted(missing_values))
Traceback (most recent call last):File "<string>", line 7, in <module>TypeError: '<' not supported between instances of 'NoneType' and 'int'
Never mind i got it. I had some fields that did not have a number they were NULL. Had to remove those. Not sure if there is a way to ignore them.
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.