Skip to main content
Solved

assign new attribute value

  • June 4, 2015
  • 3 replies
  • 30 views

Hi,

 

I want to assign value to attribute A based on the value of attribute B.

 

e.g.

 

attribute_A     attribute_B

 

   1                   type1

 

   1                   type1

 

   3                   type3

 

...9                   type9

 

  ....

 

 

I know the attributeValueAssigner can do the job. But I have to type all the unique source value (here the values in attribute B). Is there a way to query all the unique values of attribute B. And then assign related value to attribute A?

Best answer by takashi

I got it. I would use the DuplicateRemover to get unique values of the attribute_B, and write them into an external table. e.g. csv.

 

Edit the table manually to define corresponding values (A) for each value (B); and then, merge the A values read from the table to the source data with FeatureMerger or Joiner, using B value as the join key.
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.

3 replies

takashi
Celebrity
  • June 4, 2015
Hi,

 

 

If the requirement is to extract the digits part from the attribute_B, the StringSearcher with this setting might help you.

 

Search In: attribute_B

 

Regular Expression: \\d+

 

Matched Result Attribute: attribute_A

 

 

The regular expression "\\d+" matches with one or more consecutive digits, and the transformer assigns the matched part to the attribute specified in the "Matched Result Attribute" parameter.

 

 

Takashi

  • Author
  • June 4, 2015

 

Thanks. But that's not what I need. My example just gives the wrong impression.Sorry for that.

 

I need for instance, type1 -> 133,  type2 -> 343, etc. Of course, after I can get the unique values from attribute B, I need to manually assign new values to those unique values. Then apply them to the attribute A of all the features.

takashi
Celebrity
  • Best Answer
  • June 4, 2015
I got it. I would use the DuplicateRemover to get unique values of the attribute_B, and write them into an external table. e.g. csv.

 

Edit the table manually to define corresponding values (A) for each value (B); and then, merge the A values read from the table to the source data with FeatureMerger or Joiner, using B value as the join key.