AttributeManager can set attributes to null:
You can put this behind the Failed port of your AttributeValidator. You can also use the Conditional Value option if you want to only map specific attribute values to null.
Hope this helps
AttributeManager can set attributes to null:
You can put this behind the Failed port of your AttributeValidator. You can also use the Conditional Value option if you want to only map specific attribute values to null.
Hope this helps
That doesn't allow you to map only invalid attributes to null
fmeobjects commands i use: fmeobjects.FMEFeature.getAllAttributeNames, and fmeobjects.FMEFeature.setAttributeNullWithType
Which would get all attributes tied to that feature and then you could just filter out the ones you need based on the valid list and then set the rest to NULL. So like:
import fme
import fmeobjects
# Template Function interface:
# When using this function, make sure its name is set as the value of
# the 'Class or Function to Process Features' transformer parameter
def processFeature(feature):
for a in <valid attr list>:
if not a in feature.getAllAttributeNames():
feature.setAttributeNullWithType(a,fmeobjects.FME_ATTR_UNDEFINED)
pass
Another way I have done this is to have a private parameter python script setup beforehand that looks for only "the approved fields to use" and then everything else is set to NULL. This approach would work best if you know your schema ahead of time. So your private parameter would have a bunch of these return statements:
if FME_MacroValuesb'FEATURE_TYPES'] == "arc_sample_feature":
return "SRC_TYPE,COORD_SRC2,DEF_FET_TYPE,DEF_FET2,ACCURACY_FT,ST,OlID"
and then I made a python caller Python_Null_Attribute_Manager which does the same as above pretty much:
import fme
import fmeobjects
# Template Function interface:
# When using this function, make sure its name is set as the value of
# the 'Class or Function to Process Features' transformer parameter
def processFeature(feature):
for a in FME_MacroValuesg'Main_AttrComma'].split(","):
if not a in feature.getAllAttributeNames():
feature.setAttributeNullWithType(a,fmeobjects.FME_ATTR_UNDEFINED)
pass
fmeobjects commands i use: fmeobjects.FMEFeature.getAllAttributeNames, and fmeobjects.FMEFeature.setAttributeNullWithType
Which would get all attributes tied to that feature and then you could just filter out the ones you need based on the valid list and then set the rest to NULL. So like:
import fme
import fmeobjects
# Template Function interface:
# When using this function, make sure its name is set as the value of
# the 'Class or Function to Process Features' transformer parameter
def processFeature(feature):
for a in <valid attr list>:
if not a in feature.getAllAttributeNames():
feature.setAttributeNullWithType(a,fmeobjects.FME_ATTR_UNDEFINED)
pass
Another way I have done this is to have a private parameter python script setup beforehand that looks for only "the approved fields to use" and then everything else is set to NULL. This approach would work best if you know your schema ahead of time. So your private parameter would have a bunch of these return statements:
if FME_MacroValuesb'FEATURE_TYPES'] == "arc_sample_feature":
return "SRC_TYPE,COORD_SRC2,DEF_FET_TYPE,DEF_FET2,ACCURACY_FT,ST,OlID"
and then I made a python caller Python_Null_Attribute_Manager which does the same as above pretty much:
import fme
import fmeobjects
# Template Function interface:
# When using this function, make sure its name is set as the value of
# the 'Class or Function to Process Features' transformer parameter
def processFeature(feature):
for a in FME_MacroValuesg'Main_AttrComma'].split(","):
if not a in feature.getAllAttributeNames():
feature.setAttributeNullWithType(a,fmeobjects.FME_ATTR_UNDEFINED)
pass
I was looking for something that works on the validation list that the AttributeValidator generates in FME, that is doing various bits of validation. I'm validating the values of the attributes not the names/schema. The python I posted grabs the attribute names that appear in the invalid list and sets those attributes to null. I just wondered if i was missing an FME way