Skip to main content
Question

Calculation in a list

  • February 9, 2014
  • 3 replies
  • 113 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.
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.

3 replies

fmelizard
Safer
Forum|alt.badge.img+21
  • 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
Celebrity
  • 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)

 

-----