Highlighted
Five Stars

THMAP output ordering

We have a requirement to create a complex xml for which we are using THMAP.

In the job we are converting the data to a CSV then from CSV we are creating the xml.THMAP.png

 

We are having a problem with the sequence. 

expected output - All elements for set 1 in CSV should come first followed by all elements of Set 2


<FEED>
    <entry 0>
    <entry 2>
    <entry 3>
    <entry 4>
    <entry 5>
    <entry 6>
    <entry 0>
    <entry 2>
    <entry 3>
    <entry 4>
    <entry 5>
    <entry 6>
<\FEED>

But THMAP is generating in below fashion

<FEED>
    <entry 0>

    <entry 0>
    <entry 2>

    <entry 2>
    <entry 3>

    <entry 3>
    <entry 4>

    <entry 4>
    <entry 5>

    <entry 5>
    <entry 6>

    <entry 6> 
<\FEED>

 

Any suggestion to address the sequencing would be helpful.

2 ACCEPTED SOLUTIONS

Accepted Solutions
Nine Stars

Re: THMAP output ordering

Hi,

 

Here is a suggestion:

1- Add an index in your input file:

Capture.PNG

2-Map it to your XML output (For every entry records)

Capture.PNG

3-Create a second map from XML to XML format that will sort your "Entry" records (Don't map the index field if you don't want it in the output):

Capture.PNG

4-Then call this second map from your first map. To do that, right click on your map and choose 'properties' then enter your second map name in "next map" field

Capture.PNG

Does it meet your requirements ?

 

Regards.

 

Eric

 

Five Stars

Re: THMAP output ordering

Thanks Eric. It worked for me.

Final Resolution : MAP1(having CSV to XML) --> MAP2 (XML to XML) Sort Applied on MAP2 --> File written to drive

8 REPLIES
Nine Stars

Re: THMAP output ordering

Hi,

 

Could you upload your map and a test input file ?

 

Eric

Five Stars

Re: THMAP output ordering

Attached is the mapper along with the test data

Five Stars

Re: THMAP output ordering

Please refer to the talend.zip folder
Nine Stars

Re: THMAP output ordering

Hi,

 

According to which input field to you want to sort your output ? id2 ? Index line number ? Other ?

 

Eric

Five Stars

Re: THMAP output ordering

Preference is to have the entries appear in the same sequence as they appear in csv.
ID2 would be the 2nd choice.

Regards
Satyakam
Nine Stars

Re: THMAP output ordering

Hi,

 

Here is a suggestion:

1- Add an index in your input file:

Capture.PNG

2-Map it to your XML output (For every entry records)

Capture.PNG

3-Create a second map from XML to XML format that will sort your "Entry" records (Don't map the index field if you don't want it in the output):

Capture.PNG

4-Then call this second map from your first map. To do that, right click on your map and choose 'properties' then enter your second map name in "next map" field

Capture.PNG

Does it meet your requirements ?

 

Regards.

 

Eric

 

Five Stars

Re: THMAP output ordering

Hi Eric - sorry was out sick.

Will try your suggested solution and let you know the out come. Thanks for your help

Five Stars

Re: THMAP output ordering

Thanks Eric. It worked for me.

Final Resolution : MAP1(having CSV to XML) --> MAP2 (XML to XML) Sort Applied on MAP2 --> File written to drive