2013-12-21

Null in FME 2014: Converting Null to Non-Null

(FME 2014 Beta Build 14223)

The NullAttributeMapper transformer has been added to FME 2014.
It can be used to convert between <null> and non-null; the functionality of the NullAttributeReplacer transformer in FME 2013 has been integrated to it.

This workspace example creates a feature having these attributes:
attrValue = NULL  *string value. not <null>
attrNull = <null>
attrEmpty = <empty>
attrMissing = <missing>
Note: Saying strictly, the feature doesn't have "attrMissing" although it appears on the Canvas. The AttributeExposer exposes attribute names, but it doesn't create any real content of attributes.







The NullAttributeMapper with this setting replaces <null>, <empty> and <missing> with a non-null value - "NULL".









The conversion is reversible. This setting replaces an attribute value with <null> if the attribute holds "NULL" or <empty>,  or is <missing>.









One of "Null", "Missing", "Empty String" and "New Value" can be specified to the replacement value, i.e. "Map To" parameter. If specifying "New Value", "New Value" parameter has to be specified.
Both "Or If Attribute Value Is" and "New Value" parameter can be also set as Attribute Value, String / Math Expression, Parameter or Conditional Value.

The NullAttributeMapper has enough functionality for converting between <null> and non-null. I think it would become one of the most frequently used transformers for workspaces performing <null> operation.

If regular expression could be used as the matching condition, it could become more powerful.

2 comments:

  1. Good finds here! We agree that this is a very powerful transformer.

    I recently used it to "merge" attributes in two feature streams. Each stream had the same attribute names, having values of YES or NO. They had a key on which to join the features. I wanted "YES" to win -- that is, when the streams were joined, if either joined feature had YES for a particular attribute, the result should have YES. I used this transformer to first map "NO" to MISSING on both streams going into a feature merger. The resulting merged feature now had YES attributes only, nicely merged. And so I afterwards did a reverse, changing any MISSING to "NO".

    Very handy.

    ReplyDelete
  2. Thank you for the tip. That is to say, "conditional attribute removing"; we can replace Tester + AttributeRemover with a NullAttributeMapper.
    It seems that the NullAttributeMapper can be also used effectively in various scenarios other than conversion. When I found interesting use cases, will post here.

    ReplyDelete