Pivot 300+ columns into one column
Posted: Fri Jun 15, 2007 3:29 pm
Hi,
I am in need of some help. Does anyone know if there is a relatively easy way to pivot 300 columns into rows within the one column. I have a file with 200,000 records and 300 columns. Does someone know of a better way to implement this solution other than using a Pivot Stage? If I use the pivot stage, I'm certain the job will take a huge performance hit and also there's a great chance of human error if I map each column into each output column. The following shows what the current data looks like and what I need it to be changed to.
Current Data:
Header Row Col 1 Col 2 Col 3 Col 4 Col 5 . . . Col 300
Row 1 A 1 20 50 20 30
Row 2 B 5 30 10 50 25
Row 3 C 7 50 20 80 5
Row 4 D 9 70 30 25 20
Row 5 E 15 80 70 15 10
.
.
.
Row 200,000 HH 25 65 25 10 50
TO BE:
Header Row Row 1 Row 2 Row 3 Row 4 Row 5 . . . Row 200000
Col 1 A B C D E HH
Col 2 1 5 7 9 15 25
Col 3 20 30 50 70 80 65
Col 4 50 10 20 30 70 25
Col 5 20 50 80 25 15 10
.
.
.
Col 300 30 25 5 20 10 50
Once I have pivoted the columns into rows I need to use the Header Row column to lookup to a table to pull back Ids to associate to each record.
I would appreciate any suggestions or help. Please let me know if you I need to clarify more.
Thanks!
I am in need of some help. Does anyone know if there is a relatively easy way to pivot 300 columns into rows within the one column. I have a file with 200,000 records and 300 columns. Does someone know of a better way to implement this solution other than using a Pivot Stage? If I use the pivot stage, I'm certain the job will take a huge performance hit and also there's a great chance of human error if I map each column into each output column. The following shows what the current data looks like and what I need it to be changed to.
Current Data:
Header Row Col 1 Col 2 Col 3 Col 4 Col 5 . . . Col 300
Row 1 A 1 20 50 20 30
Row 2 B 5 30 10 50 25
Row 3 C 7 50 20 80 5
Row 4 D 9 70 30 25 20
Row 5 E 15 80 70 15 10
.
.
.
Row 200,000 HH 25 65 25 10 50
TO BE:
Header Row Row 1 Row 2 Row 3 Row 4 Row 5 . . . Row 200000
Col 1 A B C D E HH
Col 2 1 5 7 9 15 25
Col 3 20 30 50 70 80 65
Col 4 50 10 20 30 70 25
Col 5 20 50 80 25 15 10
.
.
.
Col 300 30 25 5 20 10 50
Once I have pivoted the columns into rows I need to use the Header Row column to lookup to a table to pull back Ids to associate to each record.
I would appreciate any suggestions or help. Please let me know if you I need to clarify more.
Thanks!