Skip to main content
Solved

Merge Two Lists so that Elements will Alternate (using FME2013SP1)

  • July 7, 2014
  • 1 reply
  • 21 views

I would like to do what has been beautifully described on the following blog.  The issue is that I currently have FME2013SP1 and the blog is using newer transformers (NullAttributeMapper and newer functionality of FeatureMerger)

 

 

 http://fme-memorandum-takashi.blogspot.ca/2014/02/merge-two-lists-so-that-elements-will.html

 

 

I am looking for suggestions on how to get the same results but by using what is available in FME2013SP1 (until I am able to get 2014 installed).

 

 

Thank you

Best answer by takashi

Hi, thanks for visiting the blog.

 

 

Assuming you've created two data flows based on the original dataset, features on both flows have ID and List{}. ID contains unique identifier of each original feature.

 

One possible way is:

 

-----

 

1st flow:

 

Explode the list with the ListExploder, and then modify _element_index:

 

_element_index = _element_index * 2

 

The index will be 0, 2, 4, 6, ...

 

 

2nd flow:

 

Explode the list with the ListExploder, and then modify _element_index:

 

_element_index = _element_index * 2 + 1

 

The index will be 1, 3, 5, 7, ...

 

 

Send those flows to the same Sorter; sort features by ID and _element_index.

 

You can then build the required list with the ListBuilder or other appropriate transformer (Group By: ID).

 

-----

 

Hope this helps.

 

 

Takashi
View original
Did this help you find an answer to your question?
This post is closed to further activity.
It may be a question with a best answer, an implemented idea, or just a post needing no comment.
If you have a follow-up or related question, 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.

1 reply

takashi
Influencer
  • Best Answer
  • July 7, 2014
Hi, thanks for visiting the blog.

 

 

Assuming you've created two data flows based on the original dataset, features on both flows have ID and List{}. ID contains unique identifier of each original feature.

 

One possible way is:

 

-----

 

1st flow:

 

Explode the list with the ListExploder, and then modify _element_index:

 

_element_index = _element_index * 2

 

The index will be 0, 2, 4, 6, ...

 

 

2nd flow:

 

Explode the list with the ListExploder, and then modify _element_index:

 

_element_index = _element_index * 2 + 1

 

The index will be 1, 3, 5, 7, ...

 

 

Send those flows to the same Sorter; sort features by ID and _element_index.

 

You can then build the required list with the ListBuilder or other appropriate transformer (Group By: ID).

 

-----

 

Hope this helps.

 

 

Takashi

Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings