2

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.

enter image description here

1
  • 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
    Jul 25 '19 at 22:20
6

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))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.