Last active
August 29, 2015 14:17
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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