Five Stars

[resolved] how to transform row to column

hi,
i want to transform column to row. columnName and Columnvalue come from dynamic column(dyn)
column=row1.dyn.getColumnMetadata(columnIndex);
columnName=column.getName();
columnValue=(String)row1.dyn.getColumnValue(columnName);
   In output, i have columnName, columnvalue.sample example below:
AccountNumber;1223  
AccountSubType__c;bonjour
ActivityIdentificationCode__c;bonsoir
AsstEmail__pc;kpk@gmail.com
AccountNumber;1223qwx
AccountSubType__c;bonjours
ActivityIdentificationCode__c;bonsoirs
AsstEmail__pc;bs@yahoo.fr
so after, i want to have the structure below:
AccountNumber;AccountSubType__c;ActivityIdentificationCode__c;AsstEmail__pc
1223;bonjour;bonsoir;kpk@gmail.com
1223qwx;bonjours;bonsoirs;bs@yahoo.fr
i need your help
5 REPLIES
Community Manager

Re: [resolved] how to transform row to column

Hi 
Please take a look at this article about how to convert columns to rows. 
Regards
Shong

----------------------------------------------------------
Talend | Data Agility for Modern Business
Five Stars

Re: [resolved] how to transform row to column

hi shong,
i think that i'm not to express correctly. Correct topic is:how to transform row to column
i want to transform row to column.
i tried tunpivot and it don't work. sample example.i have columnName,columnValue 
"AccountNumber";"12235adssqq"
"AccountSubType__c";"bonjour"
"ActivityIdentificationCode__c";"bonsoirs"
"AsstEmail__pc";"kpk@gmail.com"
---------------------------------------
"AccountNumber";"12236ads"
"AccountSubType__c";"bonj"
"ActivityIdentificationCode__c";"bonsoir"
"AsstEmail__pc";"test@gmail.com"
 i want to have a columnName on only 1 row and other rows are columnValue . sample example:
"AccountNumber";"AccountSubType__c";"ActivityIdentificationCode__c;"AsstEmail__pc"
"12235adssqq";"bonjour";"bonsoirs";"kpk@gmail.com"
"12235ads";"bonj";"bonsoir";"test@gmail.com"
Five Stars

Re: [resolved] how to transform row to column

when i use tpivotColumnDelimited and  .i have this data file below.

 or i want to have the data file below

thank you
Community Manager

Re: [resolved] how to transform row to column

Hi
I think you don't tunpivot component correctly, you need to add a key column after you read the source data, for example:
"AccountNumber";"12235adssqq"
"AccountSubType__c";"bonjour"
"ActivityIdentificationCode__c";"bonsoirs"
"AsstEmail__pc";"kpk@gmail.com"
"AccountNumber";"12236ads"
"AccountSubType__c";"bonj"
"ActivityIdentificationCode__c";"bonsoir"
"AsstEmail__pc";"test@gmail.com"
becomes:
1;"AccountNumber";"12235adssqq"
2;"AccountSubType__c";"bonjour"
3;"ActivityIdentificationCode__c";"bonsoirs"
4;"AsstEmail__pc";"kpk@gmail.com"
1;"AccountNumber";"12236ads"
2;"AccountSubType__c";"bonj"
3;"ActivityIdentificationCode__c";"bonsoir"
4;"AsstEmail__pc";"test@gmail.com"
Below is an example showing how to add a new ID column with the values like 3,2,1,0 for every 4 lines.

Regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
Five Stars

Re: [resolved] how to transform row to column

thank you. it work well