Skip to main content

Hi!

I have a list, containing between 5 and 50 values (varying). How can I append a value to this list? I can only assume there has to be a non-pythonic way, but I struggle to find one. My approach was to use AttributeCreator, but I can't dynamically specify the position in the list. Had the list size been fixed, then that's a solution - but not in this case.

Any ideas?

You can use the ListElementCounter to find the last position, which you can then use in the AttributeCreator. Example, assuming your list is called "list{}":


You can use the ListElementCounter to find the last position, which you can then use in the AttributeCreator. Example, assuming your list is called "list{}":

Of course! I didn't see it in the popup specifying "input a number" and didn't think of this manual way to do it. Good call - this should work.

 

 

However, I can't get it to "evaluate" properly? Instead, it creates an attribute called list{@Value(_element_count)}

 

 


Of course! I didn't see it in the popup specifying "input a number" and didn't think of this manual way to do it. Good call - this should work.

 

 

However, I can't get it to "evaluate" properly? Instead, it creates an attribute called list{@Value(_element_count)}

 

 

Which version of FME are you using? I tested with FME 2016.1.3.1.

 

 


Which version of FME are you using? I tested with FME 2016.1.3.1.

 

 

Okay, now it works here too. However, it also exposes an attribute called list{@Value(count)}, which confused me. Thanks, David!
Which version of FME are you using? I tested with FME 2016.1.3.1.

 

 

Yes, the exposed list{@Value(count)} annoys us a bit.

 

For what it's worth, if you want to avoid to expose it, and also do not use Python, Tcl scripting would be an alternative. Assuming an attribute called "_newValue" stores the new value to be appended to the "_list{}".

 

Tcl Expression for a TclCaller

 

FME_SetAttribute _list{iFME_Execute NumElements _list{}]} >FME_GetAttribute _newValue]
FME Function call in an FMEFunctionCaller

 

@Tcl2("FME_SetAttribute _list{ FME_Execute NumElements _list{}]} @Value(_newValue)")
YES, I know you don't like to use Tcl, @david_r ;-)

Reply