Question

Replace missing values in all attributes (dynamic input)

  • 26 November 2019
  • 4 replies
  • 144 views

Badge

I would like to replace all <missing> values with a default value. Incoming attributes are not known before (dynamic input).

NullAttributeMapper should solve this problem, but the option "map: all attributes" does only exist for Null and Empty values.

Do you know another helpful transformer or workaround?

Thanks for your comments.

 


4 replies

Userlevel 1
Badge +10

What defines that an attribute is missing?

Badge +21

Hi @hedigerm

The NullAttributeMapper should work as long as you have all attributes defined in the schema. Make sure in the step before the NullAttributeMapper that all the attributes you need are shown when you click the arrow. Add a Logger to see which attributes are on the first feature - and then copy-paste that feature here and describe the problem a bit more detailed.

Userlevel 4

I agree with @ebygomm, the behavior is explained by the fact that you cannot know that an attribute is missing unless you expect it to be present. And the point of the dynamic schema is exactly that you don't really know what to expect :-)

Userlevel 1
Badge +10

I have in the past used some python to set missing attributes to zero, but my workflow had already defined what attributes needed to be present each time, so I used something like the following to set any missing attributes to zero

    schema = feature.getAttribute('list{}.name')
    attrNames = feature.getAllAttributeNames()
    for i in schema:
        if i not in attrNames:
            feature.setAttribute(i, 0)

Reply