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! 
6 REPLIES
Fifteen Stars

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. 
Rilhia Solutions
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
Fifteen Stars

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. 
Rilhia Solutions
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