Skip to main content
Solved

Remove the two last elements of a list

  • October 6, 2022
  • 2 replies
  • 223 views

Forum|alt.badge.img

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.

Best answer by dustin

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.

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.

2 replies

dustin
Influencer
Forum|alt.badge.img+31
  • Influencer
  • 627 replies
  • Best Answer
  • October 6, 2022

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.


Forum|alt.badge.img
  • Author
  • 20 replies
  • October 6, 2022

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!