Question

How to keep original attribute value if next one is null

  • 22 October 2022
  • 3 replies
  • 0 views

I have a very badly formed csv that I want to transfer to a table. I have managed to get a basic output to work on. But the step to keep the value of 2 identifiers (file_date, id_name) if null and transpose to the next rows till they get new values, I don't know how to do.

 

image


3 replies

Already solved it with a Python caller

Badge +7

Probably, AttributeManager transformer’s Enable Adjacent Feature Attributes capability may be of use here.

Thanks for the suggestion ranga!

I tried it and it works like a charm. Again I learned something.

 

What I was using with the Pytoncaller:

class FeatureProcessor(object):

  def __init__(self):

    self.keep_date=""

    self.keep_id=""

    self.keep_id_naam=""

    pass

 

  def input(self, feature):

    if not feature.isAttributeNull('datum'):

      self.keep_date = feature.getAttribute('datum')

    else:

      feature.setAttribute('datum',self.keep_date)

 

    if not feature.isAttributeNull('id'):

      self.keep_id = feature.getAttribute('id')

    else:

      feature.setAttribute('id',self.keep_id)   

       

    if not feature.isAttributeNull('id_naam'):

      self.keep_id_naam = feature.getAttribute('id_naam')

    else:

      feature.setAttribute('id_naam',self.keep_id_naam)       

 

etc.

 

Reply