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.
pythoncode.png
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)
<...]
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)
<...]
Hi @ieukcoca, there should be several variations on scripting, but I don't think it's essential to write a Python script in this case. I think this workflow works for you as well.