Field seperator

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
adityavarma
Premium Member
Premium Member
Posts: 104
Joined: Thu Jul 12, 2007 11:32 pm
Location: Canada

Field seperator

Post by adityavarma »

Hi All,

We have a file with records as below
ABC_123_DATA_RRR_TTT_OOO
ZXC_123_DATA_SSS_PPP_LLL

I want to fetch the all the data after 3rd delimiter
FOR EX: final output should be
RRR_TTT_OOO
SSS_PPP_LLL

Can you please help me on this
Thanks
Aditya Kutcharlapati
Mike
Premium Member
Premium Member
Posts: 1021
Joined: Sun Mar 03, 2002 6:01 pm
Location: Tampa, FL

Post by Mike »

Look in appendix B of the parallel job developer's guide for all of the transform functions available. String functions would have options for you: DCount, Index, Field, [].

It would be good to become familiar with what is available.

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

Post by chulett »

Yup! Always best to become conversant with all of the functions at your disposal. Or at least know where to go look for something to do the trick. :wink:

For this, Field() would be my first go to function.
-craig

"You can never have too many knives" -- Logan Nine Fingers
adityavarma
Premium Member
Premium Member
Posts: 104
Joined: Thu Jul 12, 2007 11:32 pm
Location: Canada

Post by adityavarma »

Thank you,

it worked with index and field

trim(Columnname[ Index(columnname,'_',3) +1,50])
Thanks
Aditya Kutcharlapati
UCDI
Premium Member
Premium Member
Posts: 383
Joined: Mon Mar 21, 2016 2:00 pm

Post by UCDI »

if the stuff is fixed width you can directly extract what you want more efficiently with right or left type functions.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

FYI, the use of Index() is unnecessary as Field() supports not only a start field but optionally how many to return... 1 is the default. Just make sure when you add it that the "how many" value is high enough. I tend to use 99 even if I know there could only be a handful. Makes what is going on more obvious IMHO. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
rameshrr3
Premium Member
Premium Member
Posts: 609
Joined: Mon May 10, 2004 3:32 am
Location: BRENTWOOD, TN

Post by rameshrr3 »

Yeah, the post is resolved, but i usually design my jobs to minimize number of Transformer stages ( a throw back to the past i guess ) - So i would have just read from the sequential file , and used a copy stage to get only the columns after the 3rd position. Or read the whole file as a string and column import after column 3. Or even use a Filter Command like awk to extract anything after the 3rd column and use that filter in the Sequential file stage.
Post Reply