THMAP output ordering

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.


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


All 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

Four Stars

Re: THMAP output ordering

Where is the zip file?

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Modern Data Engineering in the Cloud

Learn about modern data engineering in the Cloud

Watch Now

How to deploy Talend Jobs as Docker images to Amazon, Azure and Google Cloud reg...

Learn how to deploy Talend Jobs as Docker images to Amazon, Azure and Google Cloud registries

Blog

Talend API Services Publish to Talend Cloud

Learn how to publish your API Services to Talend Cloud

Watch Now