FME – Concatenate Attributes Ignoring NULL/Missing Values

concatenationfme

I've got a table with different attributes (named "source:geommetry", "source:name", "source:power"…) I'd like to concatenate to one attribute named "source_all" using FME Desktop. A blank space is supposed to be the delimiter.

The issue is that sometimes attributes are NULL which leads to an output with two (or more) blank spaces somewhere in the resulting string.

I used the StringConcatenator-Transformer (but wondering if it's possible to implement an if-statement.

Another try was using the ListBuilder and the ListConcatenator resulting in a completely emty string even if only one attribute is NULL. (Although "Drop Empty and NULL Attributes" is set to YES)

Any suggestions how to build a pretty string ignoring NULL attributes?

Screenshot FME

Best Answer

My recommendation is to build your string as you are, then go back and replace any multiple spaces with a single space.

Do that by using StringReplacer with:

  • Text to Match: \s{2,}
  • Replacement Text: (single space)
  • Use Regular Expressions: yes

The logic to coalesce and concatenate in the same step gets convoluted.

Related Question