Skip To Content

Get Count


Returns the total number of rows for a table.


  • If the input is a layer or table view containing a selected set of records, only the selected records will be counted.

  • This tool honors the Extent environment. Only those features that are within or intersect the Extent environment setting will be counted.

  • You can view the returned row count in Geoprocessing history.

  • In ModelBuilder, Get Count can be used to set up a precondition, as illustrated below. In this model, Get Count counts the number of records returned by the Select tool. If the count is zero, Buffer will not run due to the precondition.

    Using Get Count with Precondition


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.

Table View; Raster Layer

Code sample

GetCount example 1 (Python window)

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

import arcpy
arcpy.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
lyrfile = r"C:\data\streets.lyr"
result = arcpy.GetCount_management(lyrfile)
print('{} has {} records'.format(lyrfile, result[0]))

Licensing information

  • ArcGIS Desktop Basic: Yes
  • ArcGIS Desktop Standard: Yes
  • ArcGIS Desktop Advanced: Yes

Related topics