Arcpy AttributeError – Solving DescribeData Method fieldInfo Does Not Exist Issue

arcpyattributeerrorfields-attributespython-2.7

I have a script that looks at feature class inside a .gdb and prints some simple information about the attributes field. Note- these is actually only one feature class in the .gdb. I want use the arcpy.Describe method with fieldInfo. Every time the script gets to the line field_info = desc.fieldInfo, it throws the error AttributeError: DescribeData: Method fieldInfo does not exist. My feature class definitely has an attribute table with fields.

What is the problem here; why is this error being thrown and how can I fix it?

My end goal is to just get a list of the field names in my feature class attributes table:

import arcpy, sys, os

arcpy.env.workspace = r"C:/Workspace/Sandbox/MapChangeProject/data/Alabama.gdb"

fcList = arcpy.ListFeatureClasses()
for fc in fcList:
    print("FeatureClass: {}").format(fc)
    desc = arcpy.Describe(fc)

    field_info = desc.fieldInfo
    for index in range(0, field_info.count):
        print("Field Name: {0}".format(field_info.getFieldName(index)))

Best Answer

From ArcGIS Documentation:

FieldInfo Summary: Provides field info methods and properties for layer and table views.

Does not work on GDBs or FCs straight up. Need to convert to a FeatureLayer first.

I would suggest using arcpy.ListFields instead. There are direct GDB methods that you can use instead. I've never used the Describe stuff before.

Related Question