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.
4 REPLIES
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.