Page 1 of 1
Field seperator
Posted: Thu Jun 01, 2017 3:05 pm
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
Posted: Thu Jun 01, 2017 3:51 pm
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
Posted: Thu Jun 01, 2017 5:03 pm
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.
For this,
Field() would be
my first go to function.
Posted: Fri Jun 02, 2017 8:52 am
by adityavarma
Thank you,
it worked with index and field
trim(Columnname[ Index(columnname,'_',3) +1,50])
Posted: Fri Jun 02, 2017 12:43 pm
by UCDI
if the stuff is fixed width you can directly extract what you want more efficiently with right or left type functions.
Posted: Fri Jun 02, 2017 12:56 pm
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 :wink:](./images/smilies/icon_wink.gif)
Posted: Fri Jun 02, 2017 3:42 pm
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.