Skip to main content

Or ‘list slicing’ of course.  For example this list with element positions also as values for illustration:

List>0,1,2,3,4]

A following AttributeManager wants to extract:

Attribute1 = List{0} so would retrieve the value of ‘0’

Attribute2 = List{1} would retrieve ‘1’

Attribute3 = List{2:} or {List{2:5} or List{2:-1} would retrieve ‘2,3,4’

Doing this without python would save time and also those without python skills would benefit.  I am aware of the ListSlicer and ​@takashi could correct me if I’m wrong but it doesn’t quite seem to achieve this if the element range is open-ended or goes from e.g. element 2 to the end of the list.  Maybe it’s just an enhancement to that transformer?

A ListIndexRetriever type transformer might be a good way to do this, or bake it into attribute transformers in addition to the current single-element functionality.

Just correcting the second example for Attribute3 - this would be List{2:4} in this case


Have you looked at the ListElementExtractor from FME Hub?

 


Have you looked at the ListElementExtractor from FME Hub?

 

It needs to be able to extract a slice that is open-ended e.g. from an index to the end of the list, into one attribute.  The ListElementExtractor and Takashi’s ListSlicer don’t cover the functionality I’m suggesting.


You can remove the superfluous list elements with a BulkAttributeRemover, and use ListConcatenator to combine the remaining list elements into a single attribute.

The regular expression used in the example below is _IDs\{s0|1|2|3]\} (the list is named _IDs, the list elements ro remove are 0, 1, 2 and 3, and the curly brackets need to be escaped with a \ because they have a special meaning in regular expressions).