help in the below logic

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
pandeesh
Premium Member
Premium Member
Posts: 1399
Joined: Sun Oct 24, 2010 5:15 am
Location: CHENNAI, TAMIL NADU

help in the below logic

Post by pandeesh »

My input sequential file has only one varchar column.
My requirement is,if the record is "abcde",
then it should be loaded as [a][c][d][e].
The length of the record is not fixed.
It may vary. if the input is "123" then the result should be [1][2][3].
One way i can think of is,using the below in filter command:

Code: Select all

sed 's/^\(.\)/[&]/g'
May i know how we can achieve this in Transformer?

Thanks
pandeeswaran
BI-RMA
Premium Member
Premium Member
Posts: 463
Joined: Sun Nov 01, 2009 3:55 pm
Location: Hamburg

Post by BI-RMA »

Hi pandeesh,

In 8.5 You could use a loop variable in the transformer to do this. But before that I would bet that everything You could do in a transformer will be too much effort to think of anything else than Your mentioned solution.

If the length of Your column was never longer than Varchar(5) You might think of using stage-variables (one per position in the string) and concatenate the results. But I would not prefer that, really.
"It is not the lucky ones are grateful.
There are the grateful those are happy." Francis Bacon
pandeesh
Premium Member
Premium Member
Posts: 1399
Joined: Sun Oct 24, 2010 5:15 am
Location: CHENNAI, TAMIL NADU

Post by pandeesh »

Unfortunately i am in 7.5 .is there any other feasible solution for this?
Last edited by pandeesh on Mon Jan 02, 2012 10:38 am, edited 1 time in total.
pandeeswaran
soumya5891
Participant
Posts: 152
Joined: Mon Mar 07, 2011 6:16 am

Post by soumya5891 »

Is your maximum length of that particular is fixed?
Soumya
pandeesh
Premium Member
Premium Member
Posts: 1399
Joined: Sun Oct 24, 2010 5:15 am
Location: CHENNAI, TAMIL NADU

Post by pandeesh »

let us consider 20. So based on the length we need to split and enclose [] in transformer.
That's complex than the filter command method.
However thanks for your inputs.
pandeeswaran
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

This would be trivial in a Server routine.
-craig

"You can never have too many knives" -- Logan Nine Fingers
pandeesh
Premium Member
Premium Member
Posts: 1399
Joined: Sun Oct 24, 2010 5:15 am
Location: CHENNAI, TAMIL NADU

Post by pandeesh »

yes. Here it's:

Image

Thanks
pandeeswaran
qt_ky
Premium Member
Premium Member
Posts: 2895
Joined: Wed Aug 03, 2011 6:16 am
Location: USA

Post by qt_ky »

Take the caret symbol ^ out of your sed command or else it will only act on the first character of each line. You can do it like this also:

Code: Select all

sed 's/./[&]/g' 
Choose a job you love, and you will never have to work a day in your life. - Confucius
pandeesh
Premium Member
Premium Member
Posts: 1399
Joined: Sun Oct 24, 2010 5:15 am
Location: CHENNAI, TAMIL NADU

Post by pandeesh »

qt_ky wrote:Take the caret symbol ^ out of your sed command or else it will only act on the first character of each line. You can do it like this also:

Code: Select all

sed 's/./[&]/g' 
yes.This is the correct one.
pandeeswaran
Post Reply