Skip to content

Instantly share code, notes, and snippets.

@hwidlund
Last active May 4, 2016 23:50
Show Gist options
  • Select an option

  • Save hwidlund/d7fa3aa7892c0241e85d160a2500f8ac to your computer and use it in GitHub Desktop.

Select an option

Save hwidlund/d7fa3aa7892c0241e85d160a2500f8ac to your computer and use it in GitHub Desktop.
Snippets for returning subsets of feature class fields
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