I think a PythonCaller would be best for this. You can convert your string to list oldlist using split(';'), create an empty list newlist, loop over your oldlist and append all the elements which are not yet in your newlist to that newlist.
Using join() you can convert your newlist back to a string.
You could also accomplish the same thing using regular transformers (no Python):
- AttributeSplitter on ; and set "Drop emtpy parts" to yes
- ListDuplicateRemover on the resulting list attribute
- ListConcatenator to join the remaining list elements together with ;
If you have a lot of further processing downstream from this, you will want to use e.g. an AttributeManager to remove the temporary attributes such as the parts list before continuing
If you want to go the Python route, here's an example:
import fmeobjects
def RemoveDuplicates(feature):
value = feature.getAttribute('value') or ''
parts = value.split(';')
unique_parts = set(parts)
joined_parts = ';'.join(unique_parts)
feature.setAttribute('new_value', joined_parts)
It will assume an incoming attribute "value" and the result will be output as "new_value". Result:
You could also accomplish the same thing using regular transformers (no Python):
- AttributeSplitter on ; and set "Drop emtpy parts" to yes
- ListDuplicateRemover on the resulting list attribute
- ListConcatenator to join the remaining list elements together with ;
If you have a lot of further processing downstream from this, you will want to use e.g. an AttributeManager to remove the temporary attributes such as the parts list before continuing
If you want to go the Python route, here's an example:
import fmeobjects
def RemoveDuplicates(feature):
value = feature.getAttribute('value') or ''
parts = value.split(';')
unique_parts = set(parts)
joined_parts = ';'.join(unique_parts)
feature.setAttribute('new_value', joined_parts)
It will assume an incoming attribute "value" and the result will be output as "new_value". Result:
Thanks. That worked fine for me.