Skip to main content

Hello all,

I have a pythonCaller in my script where I am populating an array with all the attribute names from the feature

test_fields = feature.getAllAttributeNames()

how do I go about excluding any fme generated features (example: fme_feature_type). I can't quite work out the syntax. Any help will be appreciated. Thanks

 

 

Attributes added by FME usually have a prefix of "fme_", so this is one way to exclude them:


test_fields = filter(lambda name: not name.startswith('fme_'), feature.getAllAttributeNames())

Attributes added by FME usually have a prefix of "fme_", so this is one way to exclude them:


test_fields = filter(lambda name: not name.startswith('fme_'), feature.getAllAttributeNames())
@carsonlam you are a life saver! Thank you so much! That is such a simple solution. I was battling with conditional statements.

 


Attributes added by FME usually have a prefix of "fme_", so this is one way to exclude them:


test_fields = filter(lambda name: not name.startswith('fme_'), feature.getAllAttributeNames())
Great answer by Carson. Here's the same thing using list comprehension:

 

test_fields = 

Reply