Skip to main content
Question

python shutdown attribute from feature writer

  • June 28, 2016
  • 1 reply
  • 38 views

rudy_v
Contributor
Forum|alt.badge.img+6

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

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

1 reply

takashi
Celebrity
  • June 28, 2016

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