Pivot Column to Row

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
DS4DRIVER
Premium Member
Premium Member
Posts: 39
Joined: Thu Oct 30, 2003 1:37 pm

Pivot Column to Row

Post by DS4DRIVER »

Hi,
The Source file for my job is actually a file created from an XML Source file. The XML Source file contains Data in the Heirarchy of an Excel Workbook. That is, Sheet -> Row -> Column -> Data.
The Output file from the XML source for one of the Sheets, looks like this. The First Column is Row, the Next is Column and the last is the Data pertaining to that row and column (Cell Data).

0,0,"BRS Last Updated:"
0,1,"08/01/2002"
2,0,"Table Feature"
2,1,"Requirement"
3,0,"Physical Target Database:"
3,1,"CDWP"
4,0,"Business Target Database:"
4,1,"Corporate Data Warehouse"
5,0,"Business Table Name:"
5,1,"Accounting Period Loan Unpaid Principal Balance History"
6,0,"Physical Table Name:"
6,1,"acct_per_ln_upb_hs "

Based on the above Source file, i need to create a output file that contains the Data of Column 0 of every row to be one row, and, Data of Column 1 of everyrow to be one row. So, there should be two rows in the Output file.
Can somebody tell me how this can be accomplished.

Thanks.
roy
Participant
Posts: 2598
Joined: Wed Jul 30, 2003 2:05 am
Location: Israel

Post by roy »

Hi,
How many different situations you might have ?
is it only 0 and 1?
if it is a finite nimber and not to big it might be done simply by splitting the rows via different output links of a transformer or concatenating stage variables,or sort the data and then with simple stage variable concatenate the rows utill your key column's value changes.
if it is dynamic and unforseen you might need some DS Basic routine that will dynamically store the data and then write it to a file.
that is the main idea.
also you might want to take a peek at the row merger stage (if you have 7.1)

IHTH,
Roy R.
Time is money but when you don't have money time is all you can afford.

Search before posting:)

Join the DataStagers team effort at:
http://www.worldcommunitygrid.org
Image
Post Reply