Miha_K

Count features in geodatabase

Discussion created by Miha_K on Feb 22, 2017
Latest reply on Feb 23, 2017 by nlgis_max

I am new to python and I would to like to count the number of features in each feature class that meet certain criteria.

In geodatabase I have many feature classes. One of the attribute field has values "number/number" --> 50/2, 99/6

I would to like to loop each feature class, select layer by attribute and count selected features, which contain sign "/" and print the result. Below is python code:

import arcpy

#Set the input workspace
arcpy.env.workspace = "d:/TMP/miha_k/zirovnica/novo/test.gdb"

fcs = arcpy.ListFeatureClasses()
cursor = arcpy.SearchCursor(fcs)

for row in fcs:
      arcpy.SelectLayerByAttribute_management(fcs, "NEW_SELECTION", "PARCELA LIKE '%/%'")
      arcpy.GetCount_management(fcs)
      print row

 

I would appreciate your help 

Outcomes