I am able to get the count of rows in Feature Class wing Python Window like
arcpy.GetCount_management("pipe")
which is properly returning the number of rows inside the pipe feature class. but in a stand alone environment by using this code
import arcpy
from arcpy import env
env.workspace = "C:/Users/auser/Documents/ArcGIS/Projects/Electric/Electric.gdb"
count = arcpy.GetCount_management("pipe")
print(count)
I am always getting 0
in result back
I also tried
import arcpy
from arcpy import env
env.workspace = "C:/Users/auser/Documents/ArcGIS/Projects/Electric/Electric.gdb/dataset"
count = arcpy.GetCount_management("pipe")
print(count)
By adding the dataset
to the env.workspace
and again I am getting the same 0
back! Can you please let me know what I am doing wrong?
1 Answer 1
You need to access the result of the GetCount tool - https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/get-count.htm
count = arcpy.GetCount_management("pipe").getOutput(0))
print(count.getOutput(0))
pipe
in a FeatureDataset?dataset
a feature dataset