Hello,
Is there a way to count records from a hosted feature class in AGOL using Python?
Thanks
@JoseSanchez, might be late response, but I hope, this answers your question:
from arcgis.gis import GIS
gis = GIS("https://www.arcgis.com", "username", "password")
# Access your feature layer
item = gis.content.get("<ITEM ID>")
layer = item.layers[0]
result = layer.query(return_count_only=True)
# Print the count of features
print("Number of features:", result)
Thank you @GeeteshSingh07
This is how I did it:
# Get FeatureLayerCollection
myCollection= signInObject.GIS.content.get('#######')
# Obtain feature layer from FeatureLayerCollection
featureLayer = myCollection.layers[0]
# Query a Feature Layer to get a Feature Set
feature_set = featureLayer.query(where="1=1")
# Assign a variable to the list of features in the Feature Set
feature_list = feature_set.features
# Count records
print(len(feature_list))
Thank you