Skip to main content

I receive data with standard attribute names but some of the attribute names can vary, is there a way of regardless of what the received attribute name is set it to a value

The table below shows how I might receive data with 1 of 5 different names for Length

So if attribute name is in received column set to the value in the required column






Recievd attribute
name
Required attribute name


LENGTH
Length


Length
Length


SEG_LENGTH
Length


Seg_Length
Length


Seg_Length
Length

I would use the AttributeCreator creating Length and as a value use the conditional value (if LENGTH Has Value. Elsif Length has value etc).


if attribute name contains "length" or "Length" or "LENGTH" (not sure if this is case sensitive), rename to "Length" in AttributeManager


You can use a Bulk Attribute Renamer with a regular expression replacement (assuming you don't have any other attributes with the word length in them)

Rename: All Attributes

Action: Regular Expression Replace

Text to Find: .*[L|l][E|e][N|n][G|g][T|t][H|h].*

String: Length


Various ways 🙂 The AttributeRenamer.

Note that this screenshot is from FME 2016. If you are using FME 2015, you have to set "No Action" to the Default Value column.


Many thanks for the suggestions

The whole idea of asking this question was to see if there
was a better way of renaming attributes than I have been doing - which was to

1 - Generate a crc value for each attribute

2 - Explode the attributes

3 - Test for invalid

4 - Value map invalid attribute to correct value

5 - Feature merge all back in to one

I tried a number of the suggestions

BULK ATTRIBUTE RENAMER - works if the input attributes are
known.

ATTRIBUTE RENAMER -
Thought I was on a winner with one but reading in to itYou cannot use the
Attribute Renamer to rename multiple reader feature type attributes with
different names to a single writer feature type attribute. Only the last reader
feature type attribute would actually be renamed. The transformer does not act
as a filter to see if the attribute already exists.

I am very grateful that Safe have introduced the ATTRIBUTE
MANAGER. On its own it was not adaptive to different datasets with different
attributes, I worked around this by creating a null instance with all the
different attributes with both invalid and valid names in an Attribute Manager
and feed this in to a second Attribute Manager which is part of the main
process - Now no matter what the dataset as long as the attribute name is in the
first Attribute Manager the end result is happiness and joy - From 40+
transformers to 4


Many thanks for the suggestions

The whole idea of asking this question was to see if there
was a better way of renaming attributes than I have been doing - which was to

1 - Generate a crc value for each attribute

2 - Explode the attributes

3 - Test for invalid

4 - Value map invalid attribute to correct value

5 - Feature merge all back in to one

I tried a number of the suggestions

BULK ATTRIBUTE RENAMER - works if the input attributes are
known.

ATTRIBUTE RENAMER -
Thought I was on a winner with one but reading in to itYou cannot use the
Attribute Renamer to rename multiple reader feature type attributes with
different names to a single writer feature type attribute. Only the last reader
feature type attribute would actually be renamed. The transformer does not act
as a filter to see if the attribute already exists.

I am very grateful that Safe have introduced the ATTRIBUTE
MANAGER. On its own it was not adaptive to different datasets with different
attributes, I worked around this by creating a null instance with all the
different attributes with both invalid and valid names in an Attribute Manager
and feed this in to a second Attribute Manager which is part of the main
process - Now no matter what the dataset as long as the attribute name is in the
first Attribute Manager the end result is happiness and joy - From 40+
transformers to 4

I'm not sure why the AttributeRenamer doesn't work for you. Note that the parameter setting is different between 2015 and 2016, as I mentioned in the previous post. Check these demos.


Reply