Combine columns together, not concatenate

Highlighted
Six Stars

Combine columns together, not concatenate

Hi all,

Trying to combine 2 columns in 1, i.e. trying to put column B values in separate rows (not trying to concatenate. I can concatenate using tMap = row1.xxx+row2.xxx). Below is an example of what I'm looking to do:

 

Original file:

Column A     |     Column B

Seattle          |     Portland

Los Angeles |     Sacramento 

 

Desired output:

Column A

Seattle

Los Angeles

Portland

Sacramento

 

 

 


Accepted Solutions
Sixteen Stars TRF
Sixteen Stars

Re: Combine columns together, not concatenate

What if you replace tLogRow by tFileOutputDelimited?

TRF

View solution in original post


All Replies
Sixteen Stars TRF
Sixteen Stars

Re: Combine columns together, not concatenate

If the order for the result doesn't matter and the output is a file, using tMap you can do:
row1.colA + "\\n" + row1.colB
The result will be:
Seattle
Portland
Los Angeles
Sacramento

TRF
Six Stars

Re: Combine columns together, not concatenate

Hi TRF,

 

Thank you for getting back! Tried it, but still concatenating the result for me. tLogRow output is:

Seattle\nPortland

Los Angeles\nSacramento.

 

Screenshots attached. (The order does not matter). 

Sixteen Stars TRF
Sixteen Stars

Re: Combine columns together, not concatenate

What if you replace tLogRow by tFileOutputDelimited?

TRF

View solution in original post

Six Stars

Re: Combine columns together, not concatenate

Ah, "and the output is a file"! Let me try that. 

Six Stars

Re: Combine columns together, not concatenate

Just tried tFileOutputDelimited -- same result as tLogRow. Still concatenating with \n. 

 

Created new tFileInputDelimited with Row Separator "\n" and Field Separator ",".

tMap still same as the screenshot. 

tFileOutputDelimited same values: row 1 = Seattle\nPortland, row 2 = Los Angeles\nSacramento

 

Six Stars

Re: Combine columns together, not concatenate

Got it! Removed one "\" from tMap. 

Sixteen Stars TRF
Sixteen Stars

Re: Combine columns together, not concatenate

Great! Sorry for the mistake.

TRF

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

Best Practices for Using Context Variables with Talend – Part 1

Learn how to do cool things with Context Variables

Blog

Migrate Data from one Database to another with one Job using the Dynamic Schema

Find out how to migrate from one database to another using the Dynamic schema

Blog

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog