Hi,
Depending on what version of FME you’re using, the easiest way would maybe be to paste your code into the AI assist in the PythonCaller and ask it to make the code work within PythonCaller.
It’s kind of hard to answer more in a more detailed way without knowing what your code looks like.
What you’re probably looking for is to replace the part of your code that writes an excel row and modify it so that it writes fme features instead.
That might look something like:
import fme
import fmeobjects
class FeatureProcessor(object):
"""Template Class Interface:
When using this class, make sure its name is set as the value of the 'Class to Process Features'
transformer parameter.
"""
def __init__(self):
"""Base constructor for class members."""
pass
def has_support_for(self, support_type: int):
"""This method is called by FME to determine if the PythonCaller supports Bulk mode,
which allows for significant performance gains when processing large numbers of features.
Bulk mode cannot always be supported.
More information available in transformer help.
"""
return support_type == fmeobjects.FME_SUPPORT_FEATURE_TABLE_SHIM
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.
"""
for whatever in whatever_you_loop:
out_feature = fmeobjects.FMEFeature()
out_feature.setAttribute("sample_attribute_name",variable)
self.pyoutput(out_feature)
def close(self):
"""This method is called once all the FME Features have been processed from input()."""
pass
def process_group(self):
"""This method is called by FME for each group when group processing mode is enabled.
This implementation should reset any instance variables used for the next group.
Bulk mode should not be enabled when using group processing.
More information available in transformer help.
"""
pass
Kind of hard to read I see, but likely you want to put your code within the input() section. This section is called once per feature, and if you just use a Creator to get the party started, this is where you want to be.
Any new attributes created in the PythonCaller will need to be exposed in the “Attributes to expose” section in the bottom of the PythonCaller.