Any thoughts?
-Sean
Any thoughts?
-Sean
import fmeobjects
# Template Function interface:
#def processFeature(feature):
# pass
# Template Class Interface:
class FeatureProcessor(object):
def __init__(self):
pass
def input(self,feature):
for tmpAttrName in feature.getAllAttributeNames():
tmpAttrVal= feature.getAttribute(tmpAttrName)
if tmpAttrVal is None:
feature.performFunction()
self.pyoutput(feature)
def close(self):
pass
i think this should help:
import fmeobjects
# Template Class Interface:
class FeatureProcessor(object):
def __init__(self):
pass
def input(self,feature):
for tmpAttrName in feature.getAllAttributeNames():
tmpAttrVal = feature.getAttribute(tmpAttrName)
if (tmpAttrVal is None) or (tmpAttrVal == ''):
feature.removeAttribute(tmpAttrName)
self.pyoutput(feature)
def close(self):
pass
To clarify, are you after a solution that checks whether ALL features have a null for a specific attribute?
The following article may help with the usage of Python and attribute checking and removal: http://fmepedia.safe.com/articles/How_To/Extracting-a-schema-subset-for-dynamic-schemas
I had a bit of a play with to see if there was a way to do this is without Python in case you are interested - here are the steps:
Mike
The python that Hendrik wrote works perfect. I like your method Mike but since we are running over 1600 transformers in the workbench as is, I would like to keep the number down as much as possible.
Thanks,
Sean
Hi
I have followed Michael Oberdries steps for using FME transformers for this but have got stuck on how to do step 7 & 8
7. Now use a AttributeFileReader to read in your single comma delimited txt string of attribute names to be deleted - this will get saved against a <new_attribute>
8. Finally use an FMEFunctionCaller transformer with the @RemoveAttributes function with syntax like @RemoveAttributes( snew_attribute] )
Can you give me some more advice please @MOberdries?
Explode the attributes.
Listbuilder on attr_name. Make list out of attr_value.
ListDuplicate remover.
Test if list_element_count =1.
Of those, test if list{0} has a value.
Yields a table of attributes where all records have empty values.
(you are talking about empty attributes, which exclude NULL or MISSING as I interpret it )
In the current FME (2014 or later), you can use the NullAttributeMapper to remove all empty and null attributes easily.