Skip to main content
Solved

Expose value Python Caller

  • October 20, 2024
  • 2 replies
  • 45 views

mr_fme
Enthusiast
Forum|alt.badge.img+9

Hi,

How can I expose the result (print), like attribute in python caller:

 

        from_value = min_iten[0]['from']
        to_value = min_iten[0]['to']
        print(f"{from_value[:-10]}")

 

Thank´s

Best answer by hkingsbury

You need to use the setAttribute() function on the feature object, then set that new attribute to be exposed.

 

Your input function should therefore look like:

    def input(self, feature: fmeobjects.FMEFeature):
        """This method is called for each feature which enters the PythonCaller. 
        Processed input features can be emitted from this method using self.pyoutput().
        If knowledge of all input features is required for processing, then input features should be 
        cached to a list instance variable and processed using group processing or in the close() method.
        """

        from_value = min_iten[0]['from']
        to_value = min_iten[0]['to']

        feature.setAttribute('attributeName',f"{from_value[:-10]}")

        self.pyoutput(feature)

And at the bottom of the PythonCaller, expose your attribute like so:
 

 

View original
Did this help you find an answer to your question?

2 replies

hkingsbury
Celebrity
Forum|alt.badge.img+55
  • Celebrity
  • Best Answer
  • October 20, 2024

You need to use the setAttribute() function on the feature object, then set that new attribute to be exposed.

 

Your input function should therefore look like:

    def input(self, feature: fmeobjects.FMEFeature):
        """This method is called for each feature which enters the PythonCaller. 
        Processed input features can be emitted from this method using self.pyoutput().
        If knowledge of all input features is required for processing, then input features should be 
        cached to a list instance variable and processed using group processing or in the close() method.
        """

        from_value = min_iten[0]['from']
        to_value = min_iten[0]['to']

        feature.setAttribute('attributeName',f"{from_value[:-10]}")

        self.pyoutput(feature)

And at the bottom of the PythonCaller, expose your attribute like so:
 

 


mr_fme
Enthusiast
Forum|alt.badge.img+9
  • Author
  • Enthusiast
  • October 21, 2024

Thank´s @hkingsbury 


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings