Example:
I've got a list: "_list" with as attributes _list{}.ratio.
- _list{0}.ratio = 0.10
- _list{1}.ratio = 0.25
- _list{2}.ratio = 0.30
And I want to add a list attribute: _list{}.ratiosum with as result:
- _list{0}.ratiosum = 0.10
- _list{1}.ratiosum = 0.35
- _list{1}.ratiosum = 0.65
In Python I would do it like this:
sumlist = []
s = 0
for i in range(len(ratio)):
s = s + ratio[i]
sumlist.append(s)
But how is the relation between the python and the list in FME? This doesn't work:
def processFeature(feature):
s = 0
for i in range(len(feature.getAttribute{'_list{}'));
s = s + ratio[i]
feature.setAttribute('_list{%d}.ratiosum' % i, s)
This gives an syntax error; it is not possible to get the length of the list with the len() function?