Page 1 of 1

Splitting a Row

Posted: Tue Aug 26, 2008 3:05 pm
by ds2000
I have to split a row based on number of characters (e.g 2 characters in the following example) to multiple rows. Which stage i can use or what is the best technique to do it.

Input: (Act and Line columns are keys)

Act Line Desc
--- ----- --------------------
5 1 ABCDEFGH
8 1 LMNOP
9 1 XY


Desired Output:

Act Line Desc
--- ----- --------------------
5 1 AB
5 2 CD
5 3 EF
5 4 GH
8 1 LM
8 2 NO
8 3 P
9 1 XY

Posted: Tue Aug 26, 2008 3:17 pm
by chulett
Transformer. Take advantage of the fact that, if properly prepared with intermixed record terminators, one 'record' can be written out by a Sequential File stage that reads back in as multiple records.

There's a FAQ posting on this very subject:

viewtopic.php?t=88639

Posted: Tue Aug 26, 2008 3:27 pm
by ray.wurlod
Investigate the Fold() function.

Posted: Tue Aug 26, 2008 3:30 pm
by ds2000
Sorry its a parallel job i could'nt update the job type. Do i still need to continue here or create a new topic ?

Posted: Tue Aug 26, 2008 3:34 pm
by chulett
Continue here. I'm pretty sure you can edit the job type as I could swear people have done so in the past.

And here I even took the time to check your posting history and saw that all of the old questions were for Server jobs, so just figured we were just in the wrong forum. :(

Posted: Tue Aug 26, 2008 3:41 pm
by ds2000
Thanks Chullet, i changed it to Px.

Source is db2 table and DESC column data is being used by other users who can update this column. So i can't split rows based on LF or any other delimiter.
I have to produce the output rows based on number of characters in DESC column. Output file is a source file for another system. See example.

Posted: Tue Aug 26, 2008 4:13 pm
by ray.wurlod
Can you parse the field into separate fields* using substring then use a Pivot stage?

* You will need enough of these to accommodate the longest possible input string.