Talend - combine two lines into one

Input example

Here is an example of my input. As you can see, the address column has 2 values ​​that I would like to split and then combine into one value.

Input data with merged cells

Expected Result

This is what should be the result, Combined values ​​in one cell.

Expected output data

Talend Conclusion

If I read the data in Talend, it will look like this:

enter image description here

+4
source share
1 answer

You must accomplish this using the tMemorizeRows component in Talend.

In fact, a rough example task might look like this:

Job layout

I use tFixedFlowInput to hard-code some of the data here, and not to read it in an Excel Sheet, but it should match what you provided as an example in the question:

Input data hard coded into a tFixedFlowInput component

tMemorizeRows , ( , , , ). . , , 2 :

tMemorizeRows component set to memorise everything but to only keep 2 rows in memory at a time

, , , tMemorizeRows, tJavaRow, ( ):

String name = "";
String address = input_row.address;
String mailingAddress = input_row.mailing_address;

if ("".equals(input_row.name)) {
    name = name_tMemorizeRows_1[1];
    address = address_tMemorizeRows_1[1] + " " + input_row.address;
    mailingAddress = mailing_address_tMemorizeRows_1[1] + " " + input_row.mailing_address;
} else {
    name = "DELETE THIS ROW";
    address = input_row.address;
    mailingAddress = input_row.mailing_address;
}

output_row.name = name;
output_row.address = address;
output_row.mailing_address = mailingAddress;

, " ". tFilterRow , :

tFilterRow component to remove the "DELETE THIS ROW" rows

:

.-----------+---------------------------+---------------------.
|                           Output                            |
|=----------+---------------------------+--------------------=|
|name       |address                    |mailing_address      |
|=----------+---------------------------+--------------------=|
|John Carter|Washington Street USA 12345|PO Box 999 USA 12345 |
|Linda Green|London Road UK E20 2ST     |PO Box 998 UK E20 2ST|
'-----------+---------------------------+---------------------'
+3

Source: https://habr.com/ru/post/1568728/


All Articles