Skip to content

Instantly share code, notes, and snippets.

@M-Bryant
Last active August 29, 2015 14:17
Show Gist options
  • Save M-Bryant/53097eed5a80f35a0144 to your computer and use it in GitHub Desktop.
Save M-Bryant/53097eed5a80f35a0144 to your computer and use it in GitHub Desktop.
Use SearchCursor to return a list of unique values in the specified field
def getUniqueFieldValuesFromTable(in_table, in_field_name):
'''
Use SearchCursor to return a list of unique values in the specified field
in_table: The feature class, layer, table, or table view <string>
in_field_name: Single field name <string>
returns: pythonList
'''
pySet = set()
with arcpy.da.SearchCursor(in_table, in_field_name) as cursor:
for row in cursor:
pySet.add(row[0])
return list(pySet)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment