Writing row as column

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
thamark
Premium Member
Premium Member
Posts: 43
Joined: Thu Jan 29, 2004 12:12 am
Location: US

Writing row as column

Post by thamark »

There are 5 rows with 6 column in it. I want to write the first row as single column of data with 5 rows in it. because remaining will be the same.

Thanks for your response in this regard.

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

Post by roy »

Hi,
covered before, do a search here.
in short you need to embed your OS's line termination sequence after each column (CR+LF= Char(13):Char(10) on windows or just LF = Char(10) on unix)
if you want to do it for the first line only use a transformer and use some manipulation on the @INROWNUM to get it done.

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
roy
Participant
Posts: 2598
Joined: Wed Jul 30, 2003 2:05 am
Location: Israel

Post by roy »

ok you need to pass the first line as is and concatenate the other lines to 1 line.
I asume you need:
col1 col2 col3 col4 col5
row 1 2 3 4 5
as your output so,
you can try to use soome hash file manupulation.

Code: Select all

 data -> transformer -> columns file
                     -> rows hash file
in the transformer branch the data into 2 files,
create a seq file holding the columns row/s
and a hash file for the row's row/s using a key that will relate to the columns row in question (you might need some stage variables for that).
since hash files update the existing row for any key antry that exists you need to concatenate the desired values to the same row so after the example you gave you'll end up with something like this:
columns file with : <dummy key if needed for hash lookup>, col1,col2,...
rows file with : <dummy key if needed for lookup>, 1,2,....
you might, as I said need some stage variables to manage the dummy key column if you need to.
now all you need is to read the seq file as your main input file and use a lookup to add the row line concatenate the 2 data sections of rows and columns using the CR+LF method I mentioned earlier (Ray remembers the inventor's name) to get 2 lines in your final output sequential file.
so you'll have something like this:

Code: Select all

derivation: col1,col2,col3,col4,col5 : Char(10) : lookup.row1 : lookup. .....
for unix Or for windows:
col1,col2,col3,col4,col5 : Char(13) : Char(10) : lookup.row1 : lookup. .....
well you need to include the field seperator for the sequential file as well between the columns you get from the lookup so add it in.
so you actually manipulating the 5th column to generate another line.

you might get it done in other ways as well, perhaps using some basic code, depending on the amount of data you need to process etc'.
so pick the one you think is best for your needs

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