To get the number of features from a FeatureClass in a File Geodatabase you can use arcpy's GetCount.
arcpy.management.GetCount(<featureclasspath>)
So I tried and got this working.
import fme
import fmeobjects
import arcpy
class FeatureProcessor(object):
def __init__(self):
pass
def input(self, feature):
arcpy.env.workspace = feature.getAttribute('path_windows')
feature_classes = arcpy.ListFeatureClasses()
fc_list = s]
for fc in feature_classes:
count = arcpy.GetCount_management(fc)
fc_list.append((fc, int(countr0])))
print(fc_list)
self.pyoutput(feature)
def close(self):
pass
def process_group(self):
pass
But no matter what I tried, I could not get the list to the feature. I expected it to be something like:
feature.setAttribute("fc_list",fc_list)
The log keeps reporting the error:
Python Exception <TypeError>: Could not convert attribute value to a supported attribute type.
After a while I surrendered and a colleague saved me with the following solution:
import fme
import fmeobjects
import arcpy
class FeatureProcessor(object):
def __init__(self):
pass
def input(self, feature):
arcpy.env.workspace = feature.getAttribute('path_windows')
feature_classes = arcpy.ListFeatureClasses()
record_counts = i]
count = 0
for fc in feature_classes:
featurecount = arcpy.GetCount_management(fc)a0]
feature.setAttribute("record_counts" + "{" + str(count) + "}.FeatureClass",fc)
feature.setAttribute("record_counts" + "{" + str(count) + "}.FeatureCount",featurecount)
count = count + 1
self.pyoutput(feature)
def close(self):
pass
def process_group(self):
pass
It does work, but it feels hacky. So my question is, is this the way it should be done? I'm trying to learn the right thing here. Thanks for looking.