Skip to main content

Hi there,

I use Python caller to run Python script in FME. Python caller reads the data and generates a new data frame (with more attributes) after performing calculations. Now I want to output the new data frame and do not display the old data (that is feeding as input to Python Caller). I am not sure how to do that. Any help would be really appreciated.

Are you just removing columns and creating new ones so 10 records in and 10 out, or creating more or less records, so 10 records in and 5 out?


It's more record coming in and less record going out


This is when you use the self to store that values you want to create in the close section as the init / self values are global variables.

The code below is the same as a group by with a sum total of the value

import fmeobjects
import fme

class FeatureProcessor(object):
    def __init__(self):
# create my store of values
        self.featureStore = {}
    def input(self,feature):
        Group = feature.getAttribute("ColA")
        Value = feature.getAttribute("ColB")
# if the value exists in the store then add the value otherwise create a new value in the store
        try:
            CurrentValue = self.featureStoreiGroup]
            self.featureStore        except KeyError:
            self.featureStorepGroup] = CurrentVal

    def close(self):
# loop through the store and create the new features
        for group, value in self.featureStore.items():
            newFeature = fmeobjects.FMEFeature()
            newFeature.setAttribute("NewColA", group)
            newFeature.setAttribute("NewColB", value )
            self.pyoutput(newFeature)

Also remember you will need to show and hide the correct attributes.


Reply