4

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

2 Answers 2

4

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.

4

I think the problem with your ListConcatenator is that you're selecting Listname{} as the list to concatenate. In actual fact it is expecting you to select an actual attribute in the list, for example Listname{}.name

What you could do instead is use the AttributeExploder (to create a list of attribute values all under the same list-attribute name) and then use the ListConcatenator on _attr_list{}.attr_value

The problem there is that the AttributeExploder doesn't let you choose attributes, it just uses everything, so you would need to put an AttributeKeeper before it if you wanted to be more choosy about your attribute selection.

The simplest method might be to replace null values with a fixed string (like xxxx) using the NullAttributeMapper transformer, then use the StringReplacer to look for and replace "xxxx" - a variation on the replacement idea suggested in another answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.