Skip to main content

Hi FME ninjas,

I'm working on a data source that contains school names.

 

The names in the source are too long and need to be shortened.

Left is what I have, right is what I want:

 

I know the StringReplacer can be used to correct single strings - but I fear I will need to create at least 40 of these to correct all possible strings.

Is there a transformer that can replace multiple strings? Or can this be done by Regexing some transformer? If so, how?

Thanks,

Ed

 

Hi @edhere

There is a rule to get the shortened?

For example:

On this case above is just to get the last two Words, Perfect.

But the example below?

Thanks,

Danilo


If the replacements are well defined and don't change to often, you could use the AttributeValueMapper. If not, you could also look at the SchemaMapper, which can read the replacement rules from an Excel sheet or a CSV.


If the replacements are well defined and don't change to often, you could use the AttributeValueMapper. If not, you could also look at the SchemaMapper, which can read the replacement rules from an Excel sheet or a CSV.

Hi @david_r,

 

 

The strings that need to be replaced are well defined.

 

How would I populate the AttributeValueMapper or SchemaMapper? I haven't worked with these before.

 

 

Thanks,

 

Ed

 


Hi @david_r,

 

 

The strings that need to be replaced are well defined.

 

How would I populate the AttributeValueMapper or SchemaMapper? I haven't worked with these before.

 

 

Thanks,

 

Ed

 

For the AttributeValueMapper you can simply type in the from/to strings, or you can import them from e.g. an Excel file. I would recommend having a look in the help section first, if you're not sure how it works. It's fairly simple, however.

 

 

For the SchemaMapper it's a bit more complicated, but here's a starting point:

 

https://knowledge.safe.com/articles/1136/schemamapper-transformer-tutorial.html

Bit late in answering here, but hopefully still helpful: you can try the StringPairReplacer. It does require space-separated replacement pairs so if your text to replace contains spaces they'll need to be escaped.


Bit late in answering here, but hopefully still helpful: you can try the StringPairReplacer. It does require space-separated replacement pairs so if your text to replace contains spaces they'll need to be escaped.

Solution from @Hans van der Maarel​ is what I have used to bulk search and replace 110 different strings, over more than 1000 xml files.

 

My initial columns "to_search" and "replaced_by" was merged into one column (using AttributeCreator) with a space in the middle. Aggregator was then used to create a single line of string, making sure to use a space as the separator character.

 

Result was copied and insert in StringPairReplacer.


Reply