• Index
  •  » Talend Open Studio for Data Integration » Usage, Operation
  •  » [resolved] Transpose Rows to Columns

#1 2007-10-29 16:03:14

rjs
New member
Registered: 2007-10-29
Posts: 7

[resolved] Transpose Rows to Columns

Tags: [bug, perl, pivot, tos2.2.0]

Hi,

I'm trying to simulate a transpose function in TOS 2.2.0 (perl).

Here is an example of my input lines and what I pretend to get on output:

  Input
    1|A|5
    1|B|3
    2|A|1

  Output
    1|5|3
    2|1|

Since I didn't find any component to do it directly, nether a topic in the forum talking about this issue, I tried three different approach, but all without success:

    1- Using a tAggregateRow component, I can't manipulate correctly the rows to generate all final columns

    2- Using a tSortRow+tPerl with a loop to read lines from stdin until rowId change and then print to stdout the final row with all columns, I can't get data from stdin

    3- Using a tSortRow+tPerlFlex+tMap+tUniqRow, I have problems accessing the data in tPerlFlex fields (with $tPerlFlex_1[0])

The problem with the third approach seems to be a bug (maybe I'm wrong) using the fields from tPerlFlex_1 array because a get no data. If I say directly that $colA='5' and $colB='3' then I get the pretended result for the first output row, but if I say $colA=$tPerlFlex_1[1] and $colB=$tPerlFlex_1[2] both variables steels empty.

If someone could help me solving this issue with one of these 3 approaches or a new one, I will appreciate.

Thanks in advance.

RJS

Offline

#2 2007-10-29 16:15:05

mhirt
Talend team
Registered: 2006-09-19
Posts: 1641

Re: [resolved] Transpose Rows to Columns

Hello,

This transformation is a Denormalization : you can use directly the tDenormalize (see documentation).
Someone of the Perl team will probably answer about the bug in approach 3.

Regards,

Offline

#3 2007-10-29 16:50:07

rjs
New member
Registered: 2007-10-29
Posts: 7

Re: [resolved] Transpose Rows to Columns

Thanks mhirt!

I'd passed my eyes on tDenormalize without reading well the documentation and I thought it wasn't for my issue. Now I've read correctly and I think it solves my problem.

Once again, thanks for your quickly answer.

RJS

Offline

#4 2007-11-22 18:09:39

plegall
Member
Registered: 2006-09-19
Posts: 1586
Website

Re: [resolved] Transpose Rows to Columns

Doesn't tPivotOutputDelimited fit your need? see [Bugtracker, feature 2299, fixed] New component tPivotOutputDelimited

Offline

#5 2007-11-22 19:05:44

rjs
New member
Registered: 2007-10-29
Posts: 7

Re: [resolved] Transpose Rows to Columns

The answer is no. Thanks anyway, but I solved the problem with tDenormalize.

RJS

Offline

#6 2009-03-17 08:45:36

capricornday
New member
Registered: 2009-03-11
Posts: 9

Re: [resolved] Transpose Rows to Columns

Helo. i'am newbe in talend with java big_smile

i have a mySql table like this :
init      descrip         value
A        limit             9
A        rate             0
B        limit             8
B        rate             0

and i want to make output like this:

init      limit        rate
A          9           0
B          8           0

i've try used tDenormalize and put :
column           delimiter          merge same value
descrip                ""                     [   ]

but didn't work.
do you have any solution?


regards,

capricornday

Offline

#7 2009-03-17 09:21:18

shong
Talend team
Registered: 2007-08-29
Posts: 10310
Website

Re: [resolved] Transpose Rows to Columns

Hello capricornday

The tPivotOutputDelimited  can fit your need. Please see [Forum, topic 1714] tPivot and learn its usage.

Best regards

         shong


Email:shong@talend.com
Choose Talend, Enjoy Talend!
New & Event: Talend Help Center
Talend-->the leader of open source data management and application integration solutions!

Offline

#8 2009-03-17 10:04:59

capricornday
New member
Registered: 2009-03-11
Posts: 9

Re: [resolved] Transpose Rows to Columns

thanks a lot shong.

i read [Forum, topic 1714] tPivot and use it.
but the output of tPivot is delimited file.
if i want to make to another mySql table,
i must convert it or there's another way to do it?

regards

capricornday

Offline

#9 2009-03-17 10:36:12

shong
Talend team
Registered: 2007-08-29
Posts: 10310
Website

Re: [resolved] Transpose Rows to Columns

Hello

but the output of tPivot is delimited file.
if i want to make to another mySql table,

After you output the result to a file, Using a tfileInputDelimited component to read the file and insert the data into DB.
eg:
do your pivot
   |
onSubJobOK
   |
tFileInputDelimited-->tMysqlOutput


Best regards
 
          shong


Email:shong@talend.com
Choose Talend, Enjoy Talend!
New & Event: Talend Help Center
Talend-->the leader of open source data management and application integration solutions!

Offline

#10 2009-03-17 12:44:00

capricornday
New member
Registered: 2009-03-11
Posts: 9

Re: [resolved] Transpose Rows to Columns

hi shong

it's work.
thanks for your help big_smile

regards
capricornday

Offline

#11 2009-12-24 15:28:05

varija
Member
Registered: 2009-12-12
Posts: 15

Re: [resolved] Transpose Rows to Columns

Hi I am new to Talend.I need to to convert columns to rows
for example:


input is

id    first_name   last_name   phone_number
1    Varija           Hegde          123456
2    Srini             Jala              45678

I want output to be

1  first_name  varija
1  last_name  hegde
1  phone_number  123456
2  first_name  srini
2  last_name  jala
2  phone_number  45678

Can anyone help me on this

Last edited by varija (2009-12-24 15:30:35)

Offline

#12 2009-12-25 03:30:16

shong
Talend team
Registered: 2007-08-29
Posts: 10310
Website

Re: [resolved] Transpose Rows to Columns

Hello varija

The tUnpivotRow component provided by daztop can fit your need. see the related [Forum, topic 5698] Unpivot / Talend component question.

Best regards

         shong


Email:shong@talend.com
Choose Talend, Enjoy Talend!
New & Event: Talend Help Center
Talend-->the leader of open source data management and application integration solutions!

Offline

#13 2009-12-26 10:33:39

varija
Member
Registered: 2009-12-12
Posts: 15

Re: [resolved] Transpose Rows to Columns

Thank you Shong.
I dont see tUnpivotrow in talend.I can see only tpivotToColumns under file-->output category when filter for pivot.
I am using java project in talend open source 3.2.2.r33000.
Please let me know Iam missing something.

Thanks
Varija.

Last edited by varija (2009-12-26 10:47:59)

Offline

#14 2009-12-26 13:01:12

shong
Talend team
Registered: 2007-08-29
Posts: 10310
Website

Re: [resolved] Transpose Rows to Columns

Hello Varija
tUnpivotrow component is not official component, it is created by daztop. You can download it from the below url:
http://talendforge.org/exchange/tos/ext … hp?eid=148
To install a external component, simple follows steps:
1)Download the component from url as above, unzip that archive file.
2)Copy the component folder, go to your installation direcotory\plugins\org.talend.designer.components.localprovider_3.0.3.r21383\componentsand paste it.
3)Restart TOS/TIS.

Best regards
 
          shong


Email:shong@talend.com
Choose Talend, Enjoy Talend!
New & Event: Talend Help Center
Talend-->the leader of open source data management and application integration solutions!

Offline

#15 2009-12-28 13:19:13

varija
Member
Registered: 2009-12-12
Posts: 15

Re: [resolved] Transpose Rows to Columns

thanks alot :-) Shong.
It worked fine.

thanks
Varija.

Offline

#16 2011-05-29 00:44:25

naga
Guest

Re: [resolved] Transpose Rows to Columns

Hi All,

I am very new to Talend and learning the things. I have exactly the same requirement as Varija and trying to use tUnpivotrow component. Whenever I add any column to the key field area it is giving "USERID cant be resolved or it is not a field" (USERID is a key field in my example). Someone please help me in this regard.
I am reading the data from a flat file which has about 15 field and I would like to use the USERID column as a key column and would normalize all the other columns.

#17 2013-01-14 14:07:26

vikram.takkar@yahoo.co.in
Member
Registered: 1970-01-01
Posts: 85
Website

Re: [resolved] Transpose Rows to Columns

You can visit http://vikramtakkar.blogspot.in/2013/01 … using.html for similar problem.

You can transpose rows to columns using tPivottoOutputDelimited component.

Thanks
Vikram


Regards
Vikram Takkar
http://vikramtakkar.com (Talend Tutorials)
skype: vikram.takkar

Offline

  • Index
  •  » Talend Open Studio for Data Integration » Usage, Operation
  •  » [resolved] Transpose Rows to Columns

Board footer

Powered by FluxBB