Skip to main content

I used a writer with the following code (working OK):

FeaturesWritten = str(FME_FeaturesWritten)

fcno = FME_FeaturesWritten.get(fc)

But i have changed it to a feature Writer (not working anymore): result is None

what should the code be to get the number of features written?

_total_features_written is the attribute in summary

Hi @rudy_v, a possible way I can think of is to save the value of '_total_features_written' as a Python global variable using a PythonCaller following to the FeatureWriter. e.g.

# PythonCaller Script Example: Save the number of features written as a global variable.
def processFeature(feature):
    global features_written
    features_written = int(feature.getAttribute('_total_features_written')) 

The global variable can be referred directly in the shutdown script.

Note that the variable will not be defined when the translation is failed or the FeatureWriter writes no features. To prevent an unexpected error in such a case, it might be better to define and initialize the global variable with the startup script. e.g.

# Startup Python Script Example: Define and initialize the global variable.
features_written = 0

Reply