BulkAttributeRenamer
Renames attributes by adding or removing prefixes or suffixes, or replacing text in regular expressions or character strings.
This transformer is useful if you need to quickly rename all your attributes. If the rename results in an empty attribute name, that attribute will be removed.
Hi SigTill,
Though I can see the usefullness of the BulkAttributeRenamer, It's the values of the attributes I need to rename, not the attributes themselves.
I'm also unsure as to the string value I would neet to use, as the source value is dynamic and unknown.
Hi,
If you just need to add suffix to attribute value unconditionally, I think the StringConcatenator can be used simply.
Or if you need to add suffix to specific value (e.g. "ROAD"), consider using "Conditional Value Setting" functionality in the AttributeCreator.
Takashi
Hi,
I think you will need to use a PythonCaller for this. Sample code:
---
import fmeobjects
# All attribute names starting with either of these strings will be left untouched
attributes_to_ignore = ("fme_", "geodb_")
# Suffix to add to attribute value
value_suffix = "_X"
def FeatureProcessor(feature):
attributes = feature.getAllAttributeNames()
for attribute in attributes:
if not filter(attribute.startswith, attributes_to_ignore):
value = feature.getAttribute(attribute)
feature.setAttribute(attribute, str(value) + value_suffix)
---
You need to make sure to verify "attributes_to_ignore" so that you don't accidentally modify feature attributes necessary for the writer.
David
Ah, misread your question, sorry. Then I guess a Pythonscript might be the best option.
Thanks guys,
It seems the standard strin concatenator works. Had to play around a bit, but that's part of the fun.
I think Takashi is right.
U can simply use an attributecreator:
attribute name: @Value(YourSourceVar)
Value:@Value(YourSourceVar)_X
u are talking about the values and not the attributenames, right?
Yes indeed, the values.
Seems to be working now. What I use is simply @Value(FEATURE)_X, with feature being my dynamic values.
For interest's sake, can anyone say how do use that same string value to make a prefix, instead of a suffix? I'm relatively new to the whole concept.
Try
X_@Value(FEATURE)
David
Thanks David, works like a charm.
Can't believe it's that simple.
Welcome to FME, Robbie, it's a lot of fun to discover how easy certain things are :-)
I misunderstood your initial question a bit, obviously. But to clarify, the script I posted above does exactly the same, but it will add the suffix to any and all attribute values present on each feature, regardless. I'll leave it here for future reference, though.
David