What is substr equivalent for transformer

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
Developer_AK
Premium Member
Premium Member
Posts: 7
Joined: Fri Jul 30, 2010 12:05 pm
Location: Atlanta

What is substr equivalent for transformer

Post by Developer_AK »

Hi All,


I got a situation where I need to perform sub string operation. Can any one tell me how to do a substr action in Transformer ?


Sample data:
2004041 xxx yyy34


This is a fixed length data. the desired out put is
Output:
year month week name code rowNo
2004 04 1 xxx yyy 34


So needs to perform a sub string operation.

Thanks
suse_dk
Participant
Posts: 93
Joined: Thu Aug 11, 2011 6:18 am
Location: Denmark

Post by suse_dk »

You need to do is define the start point and length in bracket after the source column and map it to your target column, for instance...

YourColumnName[1,4] mapped to year
YourColumnName[5,2] mapped to ...
YourColumnName[7,1]
YourColumnName[9,3]
YourColumnName[13,3]
YourColumnName[16,2]
_________________
- Susanne
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

The square brackets [] are the substring operator. So "YourSample[1,4]" will get you "2004", "YourSample[5,2]" will get you "04", etc etc.

:lol: Too slow.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

A word of warning. 2004041 might mean the 41st day of 2004. In that case you need to use StringToDate() with a mask of "%yyyy%ddd" to yield a date, then date component functions to extract the relevant pieces of date (year, month and day).
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