Question

Copying attribute values - how to set a default value in the output if blanks/nulls in the source?

  • 7 November 2016
  • 7 replies
  • 42 views

Userlevel 4
Badge +13

I need something like this: if the value is NULL or non-existent, then name field as "UNKNOW", else where bring the values assigned to it.

How can I tell FME to separate the NULL and empty cells from the numbered ones?

For example:

feature 1 has attribute ‘someattr’ == blank, then attribute ‘someoutput’ = UNKNOW

feature 2 has attribute ‘someattr’ with a value, then attribute ‘someoutput’ = the value from ‘someattr’ attribute


7 replies

Userlevel 4
Badge +13

See this workspace for an example:

attributevaluemapper.fmw

Screenshot:

Userlevel 2
Badge +16

Have a look at the NullAttributeMapper. That transformer seems to fit the description.

NullAttributeMapper

Badge +16

The AttributeManager can also be used for this if else kind of statements and the attribute mapping.

Userlevel 4
Badge +13

See this workspace for an example:

attributevaluemapper.fmw

Screenshot:

Here is a screenshot showing settings to update a TYPE attribute. In this case the source TYPE attribute has some single space values ' ', which need to be replaced with text 'UNKNOW'.

 

 

https://www.dropbox.com/s/izo4hin9o1c0hz2/Screenshot%202016-11-08%2000.15.30.png?dl=0

 

Userlevel 4
Badge +25

The AttributeManager can also be used for this if else kind of statements and the attribute mapping.

That's what I was thinking. Set it up to create 'someoutput' using the conditional option, with the condition being the value of 'someattr'

 

 

Userlevel 2
Badge +16

Have a look at the NullAttributeMapper. That transformer seems to fit the description.

NullAttributeMapper

Reading the question again: First copy 'someattr' in 'someoutput' and then use the NullAttributeMapper on 'someoutput'.

 

 

Badge +3

if the attribute exists u can also simply use a creator for this.

@SomeAttr == ""?"Empty":@SomeAttr

if misses or Null it results in a missing operand error.

Reply