Skip to main content
Question

Transformator to show all attributes without values/with only empty fields


Hi all,

I am working with a huge database with 300+ layers. Many layers are the same for each province and they have the same structure in their attribute table. Many of the attributes are empty but that differs from state to state (f. ex. height might be empty in 20 provinces and in 5 there is a value). Is there a transformator that shows me which attributes are completely empty for each layer and allows me to filter them without checking each attribute for each province individually? That would be a great help.

Thank you all :)

2 replies

dustin
Influencer
Forum|alt.badge.img+30
  • Influencer
  • May 10, 2023

I don't think there is anything 'off-the-shelf', but this could be one way to tackle it.

  • AttributeExposer exposing fme_feature_type
  • PythonCaller to create an attribute containing comma-separated attributes with null values (code below)
  • Aggregator with Group By set to fme_feature_type, creating a list of null values
  • ListDuplicateRemover to remove duplicates
  • ListConcatenator resulting in one feature per feature type, with an attribute listing all nulled attributes.

From there you could probably do your filtering.

import fmeobjects
 
def processFeature(feature):
    
    null_lst=[]
    
    for tmpAttrName in feature.getAllAttributeNames():
        tmpAttrVal = feature.getAttribute(tmpAttrName)
        if tmpAttrVal == '':
            null_lst.append(tmpAttrName)
            
    str = ','.join(null_lst)
    feature.setAttribute("null_list",str)
 

image


ebygomm
Influencer
Forum|alt.badge.img+32
  • Influencer
  • May 10, 2023

One possible way using the custom transformer NullAttributeCounter, the feature merger tests whether the count of null attributes equals the number of records in the workspace and returns the attribute name where that case is met

imagePrior to this, you may need to use a null attribute mapper to make sure empty and missing attributes are null


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