Format String

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
sainath
Premium Member
Premium Member
Posts: 138
Joined: Fri Nov 19, 2004 3:57 pm

Format String

Post by sainath »

Hi
my o/p is seq file. and i have to search for , in the string.if , is found
then each word will have to be inserted in new line.

ex
int.txt = abc , def,ghi

then
int.txt = abc
int.txt= def
int.txt= ghi

can you share your thoughts.
thks
samsuf2002
Premium Member
Premium Member
Posts: 397
Joined: Wed Apr 12, 2006 2:28 pm
Location: Tennesse

Post by samsuf2002 »

what is ur job design?
hi sam here
htrisakti3
Charter Member
Charter Member
Posts: 36
Joined: Thu Jun 10, 2004 11:22 pm

suggestion

Post by htrisakti3 »

here's my suggested approach:

1) [input seq] --> [T1] --> [output seq]
output: append
T1: Field(instr, "," , n)
n: job param = N-th occurence of word (ie: 1st=abc, 2nd=def)

2) call job (1) using another job with BASIC FOR 1..n LOOP
in your example, calling job1(n=1,2,3) .. would complete the task

3) Have another job to simply do WordNum=Count(instr, ",") & output it to some temp txt file, Call Job2 with WordNum as param.
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

Try to stick with one pass thru the file. Consider reading the entire line using a sequential stage using 1 column of metadata. Pass the entire line to a function you will write. In that function, look at the specific field that contains the data of interest. Loop thru the count of delimiters, and build a copy of the line for each pass, adding a LF as you concatenate a big string. Return the entire row back as the result. Have the job write the result to a sequential file. Because you have added LF, DataStage will only show in the monitor that it read N rows and wrote N rows, but line counting the file will show more than N rows. Now re-read the second file using fully defined column metadata and you will be fine.

Avoid running jobs inside loops.
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
sainath
Premium Member
Premium Member
Posts: 138
Joined: Fri Nov 19, 2004 3:57 pm

Post by sainath »

hi
can you guys explain little bit more clear with example.and also I have to delete original record.
pl share your thoughts
thks
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

This horizontal pivot looks very like a job for a Pivot stage to me.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Exactly... parse the columns out and then pivot. Don't think you need to 'delete' the original record, just don't pass it on.
-craig

"You can never have too many knives" -- Logan Nine Fingers
sainath
Premium Member
Premium Member
Posts: 138
Joined: Fri Nov 19, 2004 3:57 pm

HI

Post by sainath »

Hi
Thanks for your reply.
we have to parce data before using the pivot stage.
but how can we parce data based on delimitor ,.i dont know how many are there.

ex
key column txt
k1 k2 k3 k4 k5 abc,def,ghi.....


o/p

k1 k2 k3 k4 k5 abc
k1 k2 k3 k4 k5 def
k1 k2 k3 k4 k5 ghi
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

This is a different requirement from your original one, and probably deserves a separate thread. We answered the question you asked.

If you know the maximum possible number of fields, parse into this many columns, and set the remainder to NULL. Then run through a Pivot stage.
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