How to combine all the columns into a single column using tmap.

One Star

How to combine all the columns into a single column using tmap.

Hi guys,
I have a csv file with columns col1,col2,col3,col4,col5.
i created a metadatadelimeted with 5 columns, and i used a tmap to generate single column seperated by comma(,).
I want a regular expression to iterate all the columns and append to the resulted column , like for each column expression like in java.
String finalcol = null;
for each(Column col : allcolumns) {
   finalcol = finalcol + "," + col;      //requirement1.
   col = "mystring_" + col;            //requirement2.
}
dont tell newcol = col1+","+col2+","+.........etc.
because number of columns vary in my case.
Five Stars

Re: How to combine all the columns into a single column using tmap.

It sounds like you simply want to read your file using tFileInputFullRow, unless I'm missing something.
One Star

Re: How to combine all the columns into a single column using tmap.

It sounds like you simply want to read your file using tFileInputFullRow, unless I'm missing something.

yes tal00000 i tried tFileInputFullRow and aswell as tfileinputdelimited with limit 1, to get the first columns row.
and i want to modify the column names as per the requirement. append some text, change case. and some modifications.
Moderator

Re: How to combine all the columns into a single column using tmap.

Hi,
and i want to modify the column names as per the requirement. append some text, change case. and some modifications.

Could you please elaborate your case with an example with input and expected output values?
Best regards
Sabrina
--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
One Star

Re: How to combine all the columns into a single column using tmap.

Could you please elaborate your case with an example with input and expected output values?


my input csv is.
ID,NAME,NUMBER,ADDRESS
1,john,888888,US
2,joel,999999,UK

in this file extract firstline(columns.) like below.
ID,NAME,NUMBER,ADDRESS
and then from that create output like below.just append like "Comp_"+fieldvariable.
Comp_ID,Comp_NAME,Comp_NUMBER,Comp_ADDRESS

Note: in this case i gave 4 columns(ID,NAME,NUMBER,ADDRESS). But in reality i have different csv files with 100 columns(vary for each file).
they also should do the same operation.using the same job (appending given text for each column).
Hope this information is enough to understand my problem.thanks.

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