Skip to main content

I want to loop through the list ‘attribute’ in a PythonCaller and change some values, but I get an error. Line 34 is the for-loop.

 

  File "<string>", line 34, in input
Python Exception <TypeError>: 'NoneType' object is not iterable

 

Can you see the error?

 

    def input(self, feature: fmeobjects.FMEFeature):

feat = feature.getAttribute("attribute{}.attribute")

for obj in feat:
if "fme_varchar" in obj.fme_data_type:

 

 

Unfortunately you cannot read an FME list like that, you have to reference every child attribute.

Try something like:

names = feature.getAttribute("attribute{}.name")
data_types = feature.getAttribute("attribute{}.fme_data_type")
attributes = zip(names, data_types)

for (name, data_type) in attributes:
if "fme_varchar" in data_type:
# Do something
print(f"Attribute '{name}' is of type '{data_type}'")

 


Reply