Skip to main content
Solved

AttributeValueMapper equivalent to lookup and replace in more than 1 column?


davideagle
Contributor
Forum|alt.badge.img+21

I've got a dataset with lots of columns and the contents of the ones I need to tackle contain many zeros (0) and lots of ones (1)... there are also lots of 'Yes' and 'No' values. I want 'selected' columns to be checked for the existence of a 0 and it should be replaced with a 'No', 1s need to be 'Yes'.

The AttributeValueMapper will do this on 1 attribute, but I don't want 1 AttributeValueMapper per column.

An AttributeManager allows me to set conditional values, but I don't want to have to create this conditional rule for every column, even with FME 2018 supporting copy\\paste, that's too much effort.

I'm currently using 2 chained NullAttributeMappers, with one of them handling the 0 mapping to No and the other the 1 mapping to Yes.

But what would you do? I'm looking for ideally a elegant single transformer solution and really an AttributeValueMapper that could work on more than just 1 column seems to be an 'Idea' I ought to submit, but have I overlooked something blindingly obvious?

Pretty sure this could be done with Regex or Python, but what about a standard transformer?

Thanks in advance...

Best answer by takashi

Hi @1spatialdave, a possible way is to use the StringCocatenator with Overwrite Existing Attributes option and the @ReplaceString function.

@ReplaceString(@ReplaceString(@CurrentAttribute(),1,Yes),0,No)

0684Q00000ArKxhQAF.png

View original
Did this help you find an answer to your question?

2 replies

takashi
Contributor
Forum|alt.badge.img+19
  • Contributor
  • Best Answer
  • May 30, 2018

Hi @1spatialdave, a possible way is to use the StringCocatenator with Overwrite Existing Attributes option and the @ReplaceString function.

@ReplaceString(@ReplaceString(@CurrentAttribute(),1,Yes),0,No)

0684Q00000ArKxhQAF.png


davideagle
Contributor
Forum|alt.badge.img+21
  • Author
  • Contributor
  • June 5, 2018
takashi wrote:

Hi @1spatialdave, a possible way is to use the StringCocatenator with Overwrite Existing Attributes option and the @ReplaceString function.

@ReplaceString(@ReplaceString(@CurrentAttribute(),1,Yes),0,No)

0684Q00000ArKxhQAF.png

Thanks @takashi, works like a dream!

 


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings