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 ;-)

Hi All,

I am working with lists and require some guidance on the below scenario

I have list which contains 'n' elements. I would like to add a sub-element to each element in the list.

Assuming my list name called as "list{}"

Example: (My list currently looks like this)

    List{0}
        element1
        element2
        element3
    List{1}
        element1
        element2
        element3
    List{2}
        element1
        element2
        element3
    List{n}
        element1
        element2
        element3

        
I would like to add new sub-element called "element4" at the end of each list element (i.e., add "element4" as sub-element below "element3" )        

Expected Output (I would like to achieve something like below)

    List{0}
        element1
        element2
        element3
        element4
    List{1}
        element1
        element2
        element3
        element4
    List{2}
        element1
        element2
        element3
        element4
    List{n}
        element1
        element2
        element3
        element4


Would really appreciate your help in achieving the above expected output.

Thanks


Reply