Skip to main content
Question

Replace missing values in all attributes (dynamic input)

  • November 26, 2019
  • 4 replies
  • 548 views

Forum|alt.badge.img

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

ebygomm
Influencer
Forum|alt.badge.img+32
  • Influencer
  • November 27, 2019

What defines that an attribute is missing?


sigtill
Supporter
Forum|alt.badge.img+24
  • Supporter
  • November 27, 2019

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.


david_r
Evangelist
  • November 27, 2019

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 :-)


ebygomm
Influencer
Forum|alt.badge.img+32
  • Influencer
  • November 27, 2019

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)

Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings