Last active
May 4, 2016 21:28
-
-
Save hwidlund/47a7aa5f5862f19e9223e4cdb6594967 to your computer and use it in GitHub Desktop.
Snippets to work with feature class fields in Python and arcpy
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
| import arcpy | |
| featureClass = "c:/path/Geodatabase.gdb/fc" | |
| # Get a list of field objects from a feature class | |
| fcFields = arcpy.ListFields(featureClass) | |
| # Print the field names, types and lengths using string formatting | |
| for field in fcFields: | |
| print("{0}: type = {1} length = {2}".format(field.name, field.type, field.length)) | |
| # Get a list of field names from a feature class using list comprehension | |
| fieldNames = [field.name for field in arcpy.ListFields(featureClass)] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment