Solved

Remove the two last elements of a list

  • 6 October 2022
  • 2 replies
  • 20 views

Badge

Hello,

I'm very confused, I don't find how to remove the two last elements of a address list and concatenate the other words.

imageI think it's quite easy but even with the ListElementCounter, I dont find the answer!

Thank for your help.

icon

Best answer by dustin 6 October 2022, 13:34

View original

2 replies

Userlevel 3
Badge +26

Based on the screenshot, it looks like you've used an AttributeExploder. I'm assuming that you now have a common attribute that could be used to group each of the related elements now? If so, let's assume that attribute is 'ID'. (If you don't have a common attribute, you can create one prior to your AttributeExploder using the Counter transformer).

 

I would feed all the features into a StatisticsCalculator with the Group By set to ID. In the Statistics to Calculate section, set the attribute to _element_index, and check the box for max. From the Complete port of the StatisticsCalculator, feed that into a Tester. The test you want to perform is @Value(_element_index) <= @Evaluate(@Value(_element_index.max)-2). From the passed port will be the list components except the last two. Send those to an Aggregator with Group By set to ID, and use the Attributes to Concatenate parameters to build your concatenation.

Badge

Based on the screenshot, it looks like you've used an AttributeExploder. I'm assuming that you now have a common attribute that could be used to group each of the related elements now? If so, let's assume that attribute is 'ID'. (If you don't have a common attribute, you can create one prior to your AttributeExploder using the Counter transformer).

 

I would feed all the features into a StatisticsCalculator with the Group By set to ID. In the Statistics to Calculate section, set the attribute to _element_index, and check the box for max. From the Complete port of the StatisticsCalculator, feed that into a Tester. The test you want to perform is @Value(_element_index) <= @Evaluate(@Value(_element_index.max)-2). From the passed port will be the list components except the last two. Send those to an Aggregator with Group By set to ID, and use the Attributes to Concatenate parameters to build your concatenation.

yes Great it works!!

Thank you @dustin​ for your quick answer!

Reply