When I use the arcpy.ListFields()
command, a bunch of random numbers and letters are returned instead of my actual field names. I created my data set in Excel, used XY Table to Point, and exported it into a geodatabase as a feature class. I'm trying to use an UpdateCursor on this dataset but can't as the field names are not right. I'm using ArcGIS Pro.
-
Please use a light rather than black background for screenshots like these. Also, please always provide code and output as formatted text in preference to pictures. That way they are available to future searches and readable on all devices.PolyGeo– PolyGeo ♦2019年07月25日 22:20:47 +00:00Commented Jul 25, 2019 at 22:20
1 Answer 1
They're Field
objects, you need to print the Field.name
property:
[f.name for f in arcpy.ListFields(your_fc)]
Example from the Help:
Code sample
ListFields example - List field properties.
import arcpy # For each field in the Hospitals feature class, print # the field name, type, and length. fields = arcpy.ListFields("c:/data/municipal.gdb/hospitals") for field in fields: print("{0} is a type of {1} with a length of {2}" .format(field.name, field.type, field.length))