Last active
May 4, 2016 23:50
-
-
Save hwidlund/d7fa3aa7892c0241e85d160a2500f8ac to your computer and use it in GitHub Desktop.
Snippets for returning subsets of feature class fields
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
| fc = "c:/path/geodatabase.gdb/featureclass" | |
| # restrict returned fields by wildcard | |
| fieldList = arcpy.ListFields(fc,"OWN*") | |
| # restrict returned fields by field type | |
| fieldList = arcpy.ListFields(fc,"","String") | |
| # exclude required fields such as Shape and OID | |
| # (https://blogs.esri.com/esri/arcgis/2012/08/30/field-mapping-and-python-scripting) | |
| fieldNames = [field.name for field in arcpy.ListFields(fc) if not field.required] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment