How to combine 2 columns into one?

One Star

How to combine 2 columns into one?

Hey guys, TOS is amazing. However I'm having a problem combining 2 columns into 1. I've looked into using tMap, but I can't find my solution. I'm inputing from a delimited file if that makes any difference. I have 2 columns:
My input is
ID    | Category1   | Category2
| 1   |    Apparel  |   Jackets |
| 2   |    Shoes    |  Running |
My output that I want to have is
ID     |  Category
| 1    |   Apparel |
| 2    |   Jackets  |
| 3    |   Shoes    |
| 4    |   Running |

Any advice you have, would be great! 
Community Manager

Re: How to combine 2 columns into one?

This is a good exercise to get familiar with the flexibility of Talend. In order to achieve this you will need a tMap and a tNormalize component. 
In the tMap you need to join the Category1 and Category2 columns with a consistent separator. So in your output, you will want something like.....

row1.Category1 ";" row1.Category2

Then join the tMap output to the tNormalize component. The configuration of this component is pretty well explained here.
If you want to update the ID with a continuous sequence of 1 to n, then you can do that with several different components. An easy way is to use another tMap and use a tMap variable to count the rows. Use that counter in your output. 
One Star

Re: How to combine 2 columns into one?

Hi,
You need to use tSplitRow which is dedicated to split 1 rows in 2 or more.
Really simple to use with just one step.
Regards,
Fred
Highlighted
Community Manager

Re: How to combine 2 columns into one?

I forgot about the tSplitRow to be honest. I am usually dealing with data that is stored comma separated that needs to be split into different rows. 
Four Stars

Re: How to combine 2 columns into one?

 

I want to combine of two column into one but it is an interger value. I want to combine it without using tSplitRow.

 

thanks,

Kanda

Six Stars

Re: How to combine 2 columns into one?

Hi ,

 

We can combine two columns by providing comma and concatenating in TMap and then normalizing the output based on comma.

I have provided mapping and other photos.

Four Stars

Re: How to combine 2 columns into one?

Hi,

  thank you so much much aaryan for helping me

One Star

Re: How to combine 2 columns into one?

Hi,

 

Can you please provide the step by step configuration of each component to achieve this result. I am new to Talend, I want to know. Thanks in advance!

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 4

Pick up some tips and tricks with Context Variables

Blog

How Media Organizations Achieved Success with Data Integration

Learn how media organizations have achieved success with Data Integration

Read

Why Companies Move to the Cloud: 7 Success Stories

Learn how and why companies are moving to the Cloud

Read Now