Skip to main content
Solved

Calculate string values new field

  • June 5, 2019
  • 6 replies
  • 35 views

lambertus
Enthusiast
Forum|alt.badge.img+23

Dear community,

I just started with FME. I have an excel document with contains multiple columns. One column is called ‘Land Cover’. Depending on the values of 'Land Cover', I want to fill another column called 'classname' with new string values (‘Onkruid’ or ‘Gras’). The main idea is shown in the attached figure. I was trying to get this working with String Replacer or String Searcher. However, I did not manage. Could you help me out?

Kind regards, Lambertus

 

Best answer by ebygomm

Take a look at the AttributeValueMapper, you can import your lookup table from your excel sheet

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.

6 replies

ebygomm
Influencer
Forum|alt.badge.img+44
  • Influencer
  • 3427 replies
  • Best Answer
  • June 5, 2019

Take a look at the AttributeValueMapper, you can import your lookup table from your excel sheet


lambertus
Enthusiast
Forum|alt.badge.img+23
  • Author
  • Enthusiast
  • 141 replies
  • June 5, 2019

Take a look at the AttributeValueMapper, you can import your lookup table from your excel sheet

Hi @egomm, thanks for your reply. It sounds quite useful and suited for my job! I am going to try this one. It was thinking if you could also think about a solution using a Regular Expression within a String Replacer or another useful transformer?

 

Something like (in my own words):

when the string in attribute 'Land Cover' contains 'Grote_brandnetel' than write for the attribute 'classname' 'Onkruid'

when the string in attribute 'Land Cover' contains 'Gras' than write for the attribute 'classname' 'Gras'

when the string in attribute 'Land Cover' contains 'Ander, gras' than write for the attribute 'classname' 'Gras'


ebygomm
Influencer
Forum|alt.badge.img+44
  • Influencer
  • 3427 replies
  • June 5, 2019

Hi @egomm, thanks for your reply. It sounds quite useful and suited for my job! I am going to try this one. It was thinking if you could also think about a solution using a Regular Expression within a String Replacer or another useful transformer?

 

Something like (in my own words):

when the string in attribute 'Land Cover' contains 'Grote_brandnetel' than write for the attribute 'classname' 'Onkruid'

when the string in attribute 'Land Cover' contains 'Gras' than write for the attribute 'classname' 'Gras'

when the string in attribute 'Land Cover' contains 'Ander, gras' than write for the attribute 'classname' 'Gras'

Yes, you could use a conditional value within an attribute creator/manager. Probably no need for regex in this scenario

If you already have the lookup table in excel though, the AttributeValueMapper is much easier to set up and manage

 


lambertus
Enthusiast
Forum|alt.badge.img+23
  • Author
  • Enthusiast
  • 141 replies
  • June 5, 2019

Yes, you could use a conditional value within an attribute creator/manager. Probably no need for regex in this scenario

If you already have the lookup table in excel though, the AttributeValueMapper is much easier to set up and manage

 

Thanks! :)


lambertus
Enthusiast
Forum|alt.badge.img+23
  • Author
  • Enthusiast
  • 141 replies
  • June 6, 2019

Yes, you could use a conditional value within an attribute creator/manager. Probably no need for regex in this scenario

If you already have the lookup table in excel though, the AttributeValueMapper is much easier to set up and manage

 

It is not directly related to my original question but I want to do another thing as well.

My lookup table (I just showed a bit of the information in my screenshot) contains a field 'samplepoint'. For 'samplepoint'==57, I want to change values in 3 other fields in the same row as samplepoint 57.

In my own words: when samplepoint==57, value of field A will be 1, value of field B will become 2 and value of field C will become 3. This all has to happen in the same row.

I thought about the AttributeCreator, but that creates a new attribute. I want to update existing values based for one row.. Could you give advise in this? Thanks in advance!


ebygomm
Influencer
Forum|alt.badge.img+44
  • Influencer
  • 3427 replies
  • June 6, 2019

It is not directly related to my original question but I want to do another thing as well.

My lookup table (I just showed a bit of the information in my screenshot) contains a field 'samplepoint'. For 'samplepoint'==57, I want to change values in 3 other fields in the same row as samplepoint 57.

In my own words: when samplepoint==57, value of field A will be 1, value of field B will become 2 and value of field C will become 3. This all has to happen in the same row.

I thought about the AttributeCreator, but that creates a new attribute. I want to update existing values based for one row.. Could you give advise in this? Thanks in advance!

The attributecreator despite it's name will just update attribute values if the attribute already exists