Skip to main content
Question

What transformer to use to map multiple attributes?


tfcw
Participant
Forum|alt.badge.img+1
  • Participant

I'm reading from a dataset that represents boolean values as a "-1" for true and a "0" as false. I'm attempting to write these values into a dataset that represents booleans as a "Y" for true and a "N" for false.

I can make the "-1" -> "Y", "0" -> "N" conversion by using the AttributeValueMapper transformer, but that only works for one attribute at a time. The source dataset has about 20 boolean fields, so creating a transformer for each of those would be a time consuming and tedious process. I was wondering if there was some transformer I could use to map all these boolean values at once, or if there was a whole different approach I could take.

3 replies

jdh
Contributor
Forum|alt.badge.img+28
  • Contributor
  • January 8, 2016

I would go with two StringReplacers.

 

 

You select which attributes to apply them to, one for the -1 => Y, and the other for the 0 => N

erik_jan
Contributor
Forum|alt.badge.img+17
  • Contributor
  • January 8, 2016

The StringReplacer would be the easiest way to go. That one works for multiple attributes. You would need two (one for True and one for False):

Even nicer would be to use the SchemaMapper, but that takes a little more to configure.


tfcw
Participant
Forum|alt.badge.img+1
  • Author
  • Participant
  • January 8, 2016
jdh wrote:

I would go with two StringReplacers.

 

 

You select which attributes to apply them to, one for the -1 => Y, and the other for the 0 => N

Thanks, this works wonderfully


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