Solved

Wanting to replace data in multiple attributes to multiple strings of text. Is there a transformer that I can use for this?

  • 10 November 2021
  • 5 replies
  • 28 views

So I have multiple columns of data that return a yes or no value. I'm really only concerned with the yes value.

 

When the value in the Cut Grass attribute is 'Yes' - i want to replace the Yes with say "cut grass to 100mm"

Then i have another Yes value in Remove Flammable materials column and I want to replace the Yes with "remove materials".

 

Is there a multiple string replacer transformer that I can use.

 

I need to do this for approx 13 different attributes. I have read about string replacer or attribute value mapper. But whilst string replacer can replace multiple attributes to the same replacement text it doesn't allow for differing replacement text individual to a column.

icon

Best answer by geomancer 10 November 2021, 09:50

View original

5 replies

Userlevel 4
Badge +25

I think the SchemaMapper should be able to do this (but I'd struggle to tell you exactly how)

Userlevel 3
Badge +33

Maybe the Conditional Value option from the AttributeManager can help you out.

 

Badge +10

I'm not sure there is a straightforward FME solution

 

A python solution in this case is much simpler and easier to manage imo

import fme
import fmeobjects
 
def processFeature(feature):
    mydict = {'Cut_Grass':'cut grass to 100mm','Remove_Flammable_Materials':'remove materials'}
    attrs = feature.getAllAttributeNames()
    for a in attrs:
        if feature.getAttribute(a)=='Yes':
            feature.setAttribute(a,mydict[a])

 

Maybe the Conditional Value option from the AttributeManager can help you out.

 

Hi Geomancer - yep i stumbled across this...and yes it is working perfectly. Thanks for your help

 

Userlevel 4
Badge +25

I think the SchemaMapper should be able to do this (but I'd struggle to tell you exactly how)

I had a go and it was easier than I expected! You can find it in this video - about 30 minutes in, after another SchemaMapper question.

Reply