Skip to main content
Question

Calculation in a list

  • February 9, 2014
  • 3 replies
  • 94 views

Hello,

 

 

I have a many objetcs with a list (LIST_A) with N elements and a list attribute ATTR_1, i would like to know a smart way to do a expression evaluation on ATTR_1 on all elements of the list (without doing list explode doing the calculation with expression evaluator and doing a list builder).

 

 

Thanks in advance.

3 replies

fmelizard
Safer
Forum|alt.badge.img+19
  • Safer
  • February 9, 2014
Depending on the expression needed the list based transformers can be used. Although the possibilities are not great  certain statistics and simple expressions can be done .

  • Author
  • February 9, 2014
For example a simple one, like multiply by 2 the ATTR_1 on all elements of the list.

 

 


takashi
Influencer
  • February 10, 2014
I would use PythonCaller when it's desirable to avoid list explosion.

 

-----

 

# Python Example

 

# Assume every list element can be interpreted as numeric value.

 

import fmeobjects

 

def multiplyBy2(feature):

 

    for i, value in enumerate(feature.getAttribute('MyList{}')):

 

        feature.setAttribute('MyList{%d}' % i, float(value) * 2)

 

-----

Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings