PROBLEM
When using the arcpy.ListFields function in Python, no values are returned because the desired table or feature class is not found in ArcMap.
The arcpy.ListFields function only returns feature class field aliases (geodatabase) and not layer field aliases defined in ArcMap. Feature classes without set aliases fail to return values when the function is called.
Additionally, values may fail to be returned if the file is not in the Table Of Contents in ArcMap and an incomplete file path is given to ListFields.
Note:
Write the entire path, including any existing feature dataset containing the feature class.
Code:
import arcpy
field_list = arcpy.ListFields(r"folder_location\gdb_name\FeatureDatasetName\FeatureClassName")
for field in field_list:
print("{0} is a type of {1} with a length of {2}"
.format(field.name, field.type, field.length))
Article ID: 000012533
Get help from ArcGIS experts
Download the Esri Support App