Format String
Moderators: chulett, rschirm, roy
Format String
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
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
-
- Premium Member
- Posts: 397
- Joined: Wed Apr 12, 2006 2:28 pm
- Location: Tennesse
-
- Charter Member
- Posts: 36
- Joined: Thu Jun 10, 2004 11:22 pm
suggestion
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.
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.
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.
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
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
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
HI
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
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
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
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.
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.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.