need to split records into multiple records

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
HemaV
Participant
Posts: 63
Joined: Wed Jan 09, 2008 1:38 am
Location: Bangalore

need to split records into multiple records

Post by HemaV »

source file is like this:
EMPID~cpframeA~cptypeA~cpformatA~cpisleA~cpliteralA~cptermA~cpframeZ~cptypeZ~cpformatZ~cpisleZ~cpliteralZ~cptermZ~lpframeA~lptypeA~lpformatA~lpisleA~lpliteralA~lptermA~lpframeZ~lptypeZ~lpformatZ~lpisleZ~lpliteralZ~lptermZ~tryframe~trytype~tryformat~tryisle~tryliteral~tryterm~eqpframe~eqptype~eqpformat~eqpisle~eqpliteral~eqpterm
123~ABCX~MI~DD~EE~FF~A~ZXCS~MO~RR~QQ~SS~Z~ABDY~MQ~DWD~EQE~FEF~A~ZXCS~MA~RWR~QQQ~SES~Z~LPO~OP~PO~LI~KO~~LIO~IP~PI~LO~KQO~~

I want the output to look like this:
EMPID~frame~type~format~isle~literal~term
123~ABCX~MI~DD~EE~FF~A
123~ZXCS~MO~RR~QQ~SS~Z
123~ABDY~MQ~DWD~EQE~FEF~A
123~ZXCS~MA~RWR~QQQ~SES~Z
123~LPO~OP~PO~LI~KO~~
123~LIO~IP~PI~LO~KQO~~

Can you please me in resolving this
roy
Participant
Posts: 2598
Joined: Wed Jul 30, 2003 2:05 am
Location: Israel

Post by roy »

Hi,
I couldn't quite get the logic for splitting the string (perhaps due to the fact I'm short on time).
The trick to achieve this goal will be to plant a @VM between each part.
besides that you need to define the key column you wish to be in each row occurance and feed the manipulated data to a hashed file.
then you need to read from this hashed file and define the "Normalize on" section in the top right of the output tab of your hashed file to specify the column with the @VM you planted.
Don't forget to specify this column's type as MV (Multi Value) in the columns tab

IHTH (I hope This Helps),
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 »

Hi,
forgot to mention that if this is a fixed number of field you can also try the pivot stage
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
datskosaraju
Premium Member
Premium Member
Posts: 48
Joined: Tue Nov 25, 2008 11:10 pm
Location: Des Moines,IA

Post by datskosaraju »

Search for "vertical pivot"
"It's easier to go down a hill than up it but the view is much better at the top"
-Bennet,Arnold
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

I think this is just Pivot and not "Vertical" pivot.
HemaV
Participant
Posts: 63
Joined: Wed Jan 09, 2008 1:38 am
Location: Bangalore

Post by HemaV »

using pivot stage which column i need to take as key column
datskosaraju
Premium Member
Premium Member
Posts: 48
Joined: Tue Nov 25, 2008 11:10 pm
Location: Des Moines,IA

Post by datskosaraju »

Sainath.Srinivasan wrote:I think this is just Pivot and not "Vertical" pivot. ...
My bad........ I apologize for the mistake. Yes its "horizontal pivot"
"It's easier to go down a hill than up it but the view is much better at the top"
-Bennet,Arnold
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

Hema,

Not being rude, can you please explain what you tried so far so that others can help from there.

Key is the column which identifies / groups same record. So use the technique to find which column must be key.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Why not just use a Sequential File stage, declare the right number of fields delimited by "~" plus one "dummy field, and specify "none" as the record terminator?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

Ray,

The main fields occur only once and 'additional attributes' occur multiple times. So it is not just wrapping the rows to columns.
Post Reply