Skip to main content
Solved

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

  • May 30, 2018
  • 2 replies
  • 79 views

davideagle
Contributor
Forum|alt.badge.img+22

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

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

2 replies

takashi
Celebrity
  • 7843 replies
  • 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+22
  • Author
  • Contributor
  • 578 replies
  • June 5, 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

Thanks @takashi, works like a dream!