Page 1 of 1

File with multiple headers

Posted: Mon Oct 29, 2007 3:07 am
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.

Posted: Mon Oct 29, 2007 4:30 am
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.

File with multiple headers

Posted: Tue Oct 30, 2007 8:18 am
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?

Posted: Tue Oct 30, 2007 8:16 pm
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

Column to Row

Posted: Wed Oct 31, 2007 6:57 am
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?

Posted: Wed Oct 31, 2007 7:00 am
by ray.wurlod
You need other stage variables for the other columns. Please try to generalize my example.