Get Count (Data Management)

License Level:BasicStandardAdvanced

Summary

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

Usage

Syntax

GetCount_management (in_rows)
ParameterExplanationData Type
in_rows

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"
arcpy.GetCount_management("roads")
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: fcCount.py
# Purpose: calculate the number of features in a featureclass

# Import system modules
import arcpy
from arcpy import env
 
env.workspace = "C:/data/Montgomery.gdb"
lyrfile = "streets.lyr"
result = int(arcpy.GetCount_management(lyrfile).getOutput(0)) 
print result

Environments

Related Topics

Licensing Information

ArcGIS for Desktop Basic: Yes
ArcGIS for Desktop Standard: Yes
ArcGIS for Desktop Advanced: Yes
11/18/2013