Search code examples
talend

talend: how to merge columns to one other


I have one table:

|| id || val1 || val2 || val1-2 || val2-2 || val1-3 || val2-3 ||  
|  1   |  vv1  |  ww1  |   vv3   |   ww3   |   vv6   |   ww6   |   
|  2   |  vv2  |  ww2  |   vv4   |   ww4   |   vv7   |   ww7   |   

And would like to have the following:

|| id || val1 || val2 ||
|  1   |  vv1  |  ww1  |
|  2   |  vv2  |  ww2  |
|  1   |  vv3  |  ww3  |         
|  2   |  vv4  |  ww4  |         
|  1   |  vv6  |  ww6  |         
|  2   |  vv7  |  ww7  |         

So I would like to put the content of some columns under other columns.

Which talend component I can achieve this?


Solution

  • Another way to do this would be using tMap and while creating output group use "create join table from" option...see this link below http://garpitmzn.blogspot.in/2011/12/one-way-to-split-single-row-to-multiple.html

    more details given below - (as very rightly pointed out by ydaetskcoR)

    A similar example is given below - Say you have input data as

    CountryName1      CountryCode1       CountryName2      CountryCode2
    ABCDE              ABC                  XYZE             ZY
    

    What you want is to split this single row into two rows as below

    countryname        countrycode
    ABCDE              ABC                  
    XYZE                ZY
    

    one quick solution incase you have requirement like above, where you know number of rows you want to split - Take this row as input to tmap component and in tmap create one output group say out_1. Now in this out_1 drag and link countryName1 and countryCode1 columns from input. Now create another output group out_02 in this tmap and when "add a output" dialog comes select "create join table from" and in the dropdown select out_1 group, so that our output rows from this out_02 group will also go to out_01 group. So our tmap will have only one output group out_01 containing rows from both out_01 and out_02. now in out_02 drag and link countryName2 and CountryCode2 columns.

    image1 image_2 image_3