Is there no message in the log file?
The example should write key: bla, value: blabla to the Log window.
An FME List is more like a Python Dictionary, in Python a list is a group of values, where as in FME a list is a group of keys and their values.
In your first line, that will evaluate to ‘None’ so will never pass the If clause.
To get a list Attr, you need to do something like:
foo = feature.getAttribute('__list{}.attr1')
bar = feature.getAttribute('__list{}.attr2')
for f, b in zip(foo, bar):
print(f, b)
You can then iterate over them both at the same time using zip - only works if lists are the same length
There are lots of transformers that work on lists, you may easily have missed the right transformer for what you want to accomplish. Maybe this tutorial can be of help:
https://support.safe.com/s/article/working-with-list-attributes-tutorial
Thanks for the response!
I managed to solve the problem, but to me it doesn’t seem like the attributes that I access with getAttribute are typed as an ordinary Python lis/dictionaryt. It’s more like the list and dictonary is converted to pure strings when it enters the PyhonCaller. That’s what confused me when I read different examples on the internet. When I read 'dupl_attr{0}.Fritext' I thought that was a list when it just was a simple string.
The only way for me to solve the problem was to loop the number of entrys in the “list”. A number that I got through another integer value in the feature. Then create the feature name I wanted to access by creating a string which at first glance, looks like a list reference, but in fact is just a plain string.
Example:
altValues = ]
overlaps = feature.getAttribute('_overlaps')
for x in range(overlaps):
itemValues = {}
for item in self.featAttr:
itemValues.update({item:feature.getAttribute('dupl_attr{' + str(x) + '}.' + item)})
altValues.append(itemValues)
Where self.featAttr is a list created inside Python caller with names of the feature attributesI want to check. For example: s'Fritext','MarkTyp','MatOrg']
Second last row in the example creates a string that can look like this: 'dupl_attr{0}.Fritext' which is not a list type but just a string that looks like a list :)
Maybe there are other solutions but I wanted to solve this in a Pythoncaller instead of an ordinary transformer.