Get Count (Data Management)


Returns the total number of rows for a feature class, table, layer, or raster.



GetCount_management (in_rows)
ParameterExplanationData Type

The input table view or raster layer. If a selection is defined on the input, the count of the selected rows is returned.

Raster Layer; Table View

Code Sample

GetCount example 1 (Python window)

The following Python Window script demonstrates how to use the GetCount function in immediate mode.

import arcpy
from arcpy import env

env.workspace = "C:/data/data.gdb"
GetCount example 2 (stand-alone script)

The following stand-alone script is an example of how to use the GetCount function in a scripting environment.

# Name:
# Purpose: calculate the number of features in a featureclass

# Import system modules
import arcpy
from arcpy import env
lyrfile = r"C:\data\streets.lyr"
result = arcpy.GetCount_management(lyrfile)
count = int(result.getOutput(0))
print count


Related Topics

Licensing Information

ArcView: Yes
ArcEditor: Yes
ArcInfo: Yes