Page 1 of 1

format string

Posted: Sun Apr 16, 2006 10:10 am
by sainath
hi
I want to take last 10 char from a input string and add 00000 before it to make 15 character length.i just appendbed 00000:input column.is there any better way.
thks
sai

Posted: Sun Apr 16, 2006 10:40 am
by meena
Hi Sai,
You can write a stage varaible for this. There are fuctions avaible in the tranformer. Use the "substr" function to extract the wanted string from the input stream and use the fmt to pad the string with the zero's and can make the total length 15. Hope this helps you. Even I am new to DS. Try this

Meena

Posted: Sun Apr 16, 2006 10:52 am
by ArndW
You can use the derivation fmt(right(In.Column,10):"00000","15'0'R") to do what you asked.

Posted: Sun Apr 16, 2006 12:47 pm
by chulett
Try just fmt(right(In.Column,10),"15'0'R") as it looks like Arnd misunderstood the 'tacking on five zeroes' part.

Well, one of the two of us did. :wink:

Posted: Sun Apr 16, 2006 3:16 pm
by ray.wurlod
If Sainath has ten characters (guaranteed) from the input stream, then concatenation ("00000" : InLink.C10column) is the most efficient algorithm.

Posted: Sun Apr 16, 2006 4:24 pm
by chulett
Agreed, but the FMT solution seems... better. At least from an educational standpoint. :wink:

Posted: Mon Apr 17, 2006 12:39 am
by ray.wurlod
For some folks "performance" (whatever that means) is the primary goal. It's always beneficial to know the most efficient techniques, particularly for large to huge data volumes.