Creating a Job to combine two CSV files into a single XML file - 7.3

Talend Data Mapper User Guide

Version
7.3
Language
English
Product
Talend Big Data Platform
Talend Data Fabric
Talend Data Management Platform
Talend Data Services Platform
Talend MDM Platform
Talend Real-Time Big Data Platform
Module
Talend Studio
Content
Design and Development > Designing Jobs
Last publication date
2023-01-05

Create a Job with two CSV input files, a tHMap component and an output file.

Procedure

  1. In the Integration perspective of Talend Studio, right-click Job Designs > Standard and click Create Standard Job.
  2. Enter a name, purpose and description for your Job and click Finish.
  3. Add the following components:
    • Two tFileInputDelimited
    • A tHMap
    • A tFileOutputRaw
  4. Link the tFileInputDelimited components to the tHMap and the tHMap to the tFileOutputRaw with Row > Main connections.
  5. Click Yes when asked if you want to get the schema from the target component.
  6. Double-click your tFileInputDelimited components to configure them:
    1. Click the ... button to the right of the File name/Stream field and browse to your input CSV files.
    2. Click the ... button to the right of Edit schema and add the columns present in your CSV files, then click OK.
      In this example, the tFileInputDelimited component named customers should have a schema with three columns named id, name and city, and the one named bills should have three columns named customerId, billId and price.
    3. In the Header field, enter 1 to indicate that the first line of the CSV file is a header.
  7. In the Hierarchical Mapper, right click Structures and click New > Structure.
  8. Select Import a structure definition and click Next, then follow the wizard to create a structure based on an XML sample to use as an output.
    For this example, you can use the following sample. For more information, see Creating a structure from a sample document.
    <root>
       <customer>
          <id>591</id>
          <name>Billy</name>
          <city>Los Angeles</city>
          <bill>
             <id>sry-84u</id>
             <price>352.89</price>
          </bill>
          <bill>
             <id>xoi-htr</id>
             <price>36.55</price>
          </bill>
       </customer>
       <customer>
          <id>891</id>
          <name>Bob</name>
          <city>Chicago</city>
          <bill>
             <id>111-gfs</id>
             <price>3.58</price>
          </bill>
       </customer>
    </root>
    The structure opens in the editor, it should look like this:
  9. Double-click the tFileOutputRaw and enter the path to your output XML file in the Filename field.
  10. Double-click the tHMap component to configure it.
    The schemas from the tFileInputDelimited components should automatically be used as the input structure.
  11. Click Next, select the structure you created as the output and click Finish.

Results

The map is generated and opens in the editor, you can now map your elements.