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.
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)
[...]
Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.