Skip to main content
Question

Rename Attributes with names from other table


michaels
Contributor
Forum|alt.badge.img+4

I have two input features. One contains the actual data, but with the wrong attribute names. The other contains the desired attribute names plus the connection key.

Data-Feature


Attributename-Feature


Green corresponds to the attribute name in the data feature,
Red is the name of the attribute in the end
 

How can I merge the two features and/or rename them so that the correct names appear?

 

5 replies

takashi
Evangelist
  • June 5, 2025

Hi ​@michaels ,

A possible way is, merge the data-feature to the attributename-feature with FeatureJoiner or FeatureMerger, assign the data value to an attribute associated by the original attribute value (uuid) with AttributeDereferencer.

However, as you can see in the screenshot above, the method requires the same number of AttributeDereferencers as the number of target attributes. If there are many attributes, maybe scripting would be better.


j.botterill
Influencer
Forum|alt.badge.img+40
  • Influencer
  • June 5, 2025

I think you are potentially needing to use a Feature Reader to read Data-Feature and its ‘schema’ port attribute{}.name list. Obviously you’ll need to understand list manipulation Tutorial-Getting-Started-with-List-Attributes

Once you have a field with the UUID you can potentially use another feature reader/merge to bring in the Attributenames-feature. From here you what to update the attribute{} list index with the ‘name’ column. You finally connect the featureReader schema and data ports into a Writer. This is known as dynamic writing. More info Dynamic-Workflows-Components 


redgeographics
Celebrity
Forum|alt.badge.img+50

Another option would be to use the SchemaMapper, see https://support.safe.com/hc/en-us/articles/25407599862157-Tutorial-SchemaMapper-Transformer for a tutorial


michaels
Contributor
Forum|alt.badge.img+4
  • Author
  • Contributor
  • June 5, 2025
takashi wrote:

Hi ​@michaels ,

A possible way is, merge the data-feature to the attributename-feature with FeatureJoiner or FeatureMerger, assign the data value to an attribute associated by the original attribute value (uuid) with AttributeDereferencer.

However, as you can see in the screenshot above, the method requires the same number of AttributeDereferencers as the number of target attributes. If there are many attributes, maybe scripting would be better.

Hi ​@takashi 

thanks very much for your idea. Is there a way to dereferencing the attributes dynamically? Because it's a dynamic workbench and I don't know what attributes come in.

thanks for your help again 😊


takashi
Evangelist
  • June 5, 2025

I would replace the AttributeDereferencers with a PythonCaller, if the attribute names are unknown when creating the workspace.

A script example:

class FeatureProcessor(object):
    def __init__(self):
        pass

    def input(self, feature: fmeobjects.FMEFeature):
        # create a dictionary associating attribute name with its value
        d = {n : feature.getAttribute(n) for n in feature.getAllAttributeNames()}

        # replace attribute value with data referenced by the original value (uuid)
        for name, value in d.items():
            newValue = d.get(value, None)
            if newValue != None:
                feature.setAttribute(name, newValue)

        self.pyoutput(feature)

 


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