I have an aggregator transformer (to aggregate incoming features because I want a single feature to enter the subsequent Emailer transformer). I'm trying to use the python code (in PythonCaller transformer) to extract info about each of the aggregated features for output to the email. I'm using "for x in range (0, feature.getAttribute('Count')-1)" to try to loop over the lists but the workspace isn't accepting x.
Solved
How do I loop over list elements for in python caller?
Best answer by jdh
for x in range (0, feature.getAttribute('Count')-1) will not include the last item in the list, I don't know if this is intentional or not.
the @Value(list{x}.Value) syntax you get when double clicking on a list attribute in the FME Feature Attributes panel is garbage. If you select the attribute and drag and drop in the code pane you'll end up with the correct syntax of feature.getAttribute('_list{#}.Value').
In your particular case you'll probably want something like feature.getAttribute('Details{%d}.ACCOUNT_NO' % x)
Alternatively you could have a loop like
acntList = feature.getAttribute('Details{}.ACCOUNT_NO')
for i, x in enumerate(acntList):
[...]
feature.getAttribute('Details{%d}.LOCATION_NO' % i)
[...]
This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.



