finding words separated by spaces

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
sravanthi
Participant
Posts: 83
Joined: Fri Jun 02, 2006 5:37 am

finding words separated by spaces

Post by sravanthi »

Hi,

I have a situation where i need to separte words:

Ex:

My input data looks like
CHICAGO CITY
ABC XYZ
A CNBC H.

I need to separate one word char(30) into 3 words.
col1,col2,col3
CITY,CHICAGO
XYZ,ABC
CNBC,A,H.

The length of these characters in each line are different and they are not uniform through out the file.

is there are method to identify spaces among words and when found pull first and so on

Please advice!
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Use COUNT to get the number of spaces, add 1, then use FIELD to pull each of them from your space delimited string. Or skip the COUNT if it is always three (max).
-craig

"You can never have too many knives" -- Logan Nine Fingers
sravanthi
Participant
Posts: 83
Joined: Fri Jun 02, 2006 5:37 am

Post by sravanthi »

chulett wrote:Use COUNT to get the number of spaces, add 1, then use FIELD to pull each of them from your space delimited string. Or skip the COUNT if it is always three (max). ...
Thank You

I will work using this and let you know how it goes :)
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

What rule governs the order of words in the output?
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 »

Hmmm... I thought it was just bass-ackwards order but closer examination of the evidence provided by the defense suggests otherwise.
-craig

"You can never have too many knives" -- Logan Nine Fingers
sravanthi
Participant
Posts: 83
Joined: Fri Jun 02, 2006 5:37 am

Post by sravanthi »

That's my requirement :(

Is there any method to select first word and then second word sepated by spaces.

abc xyz input

output should be:
col1 col2
abc xyz

And spaces between words are different for each words.

I have tried chulett's suggestion and was able to create some records.Please advice!
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Sure. Field(InputField," ",1,1) would get the first word from a space delimited InputField, Field(InputField," ",2,1) would get the second one. Field(InputField," ",1,2) would get the first and second "word" at once. Etc.
-craig

"You can never have too many knives" -- Logan Nine Fingers
sravanthi
Participant
Posts: 83
Joined: Fri Jun 02, 2006 5:37 am

Post by sravanthi »

Thank You Chulett .

I was able to produce output file usinf field command. :D
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Cool. Time to mark this as Resolved then, using the button at the top of the screen. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply