HOW TO
In ArcGIS Desktop, the Get Count geoprocessing tool is used to calculate the total number of rows in an attribute table. However, this tool does not calculate the total number of columns, which represent the total number of fields in a feature class.
Calculating the total number of fields is useful when there are a number of attributes in a feature class. The total can be derived using the Python ListFields() function.
The workflow below describes how to calculate the total number of fields in a feature class using the Python ListFields() function.
print len(arcpy.ListFields(r"location of your feature class or shapefile","*"))
Note: For more information on the function, refer to ArcMap: ListFields.
In this example, the following expression is used to count the fields in the Counties feature class:
print len(arcpy.ListFields(r"C:\Users\*****\Desktop\Data2\State.gdb\Counties","*"))
Get help from ArcGIS experts
Download the Esri Support App