File with multiple headers

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
valar_mathi
Participant
Posts: 9
Joined: Sun Oct 28, 2007 11:57 pm

File with multiple headers

Post by valar_mathi »

Can anyone think of a solution to this problem?

I have a CSV file with header in first 2 rows and they will remain constant. Only the value in the 3 row will change. I have to load this data into a table.

Input CSV file:
Prod1,,Prod2,,Prod3
Loc1,Loc2,Loc1,Loc2,Loc3,Loc4
1,2,3,4,5,6

Output:
Prod1,Loc1,1
Prod1,Loc2,2
Prod2,Loc1,3
Prod2,Loc2,4
Prod3,Loc3,5
Prod3,Loc4,6

I think loading data into a table directly will be difficult so thought of converting this data into the Output format given above. I am new to datastage so can anyone tell me how to proceed with this.
ray.wurlod
Participant
Posts: 54595
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Load values from row #1 and row #2 (as detected by @INROWNUM) into stage variables and from there into output columns. Constrain the output @INROWNUM = 3.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
valar_mathi
Participant
Posts: 9
Joined: Sun Oct 28, 2007 11:57 pm

File with multiple headers

Post by valar_mathi »

Thank you for the reply.
I am also trying in the same way. I extracted the headers seperately but could not achieve the output. Can you pls explain in detail?
ray.wurlod
Participant
Posts: 54595
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Derive the output columns directly from the stage variables, but only in the rows where the stage variables change. For example

Code: Select all

If @INROWNUM = 1 Then InLink.Col1 Else svProc1
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
valar_mathi
Participant
Posts: 9
Joined: Sun Oct 28, 2007 11:57 pm

Column to Row

Post by valar_mathi »

It works for coverting first column into row but couldnt covert the other columns. :roll: Is it possible to achieve it in any other way?
ray.wurlod
Participant
Posts: 54595
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

You need other stage variables for the other columns. Please try to generalize my example.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply