Page 1 of 1
Appending the spaces with Zero
Posted: Wed Jul 02, 2008 3:58 am
by LavanyaRamesh007
Hi,
My requirement is such that I need to append zeros with my input file. The output length is 5. I might get an input from 1 length to 5 length. Say the input 'ABC' (length 3)
Input='ABC'
Output='ABC00'
Then my output must append two zeros. length of input is 4, then 1 zero needs to be appened..
'Kindly help me
Posted: Wed Jul 02, 2008 4:05 am
by ArndW
LEFT(In.InputColumnName:'00000',5) should do the trick for you assuming your datatype is CHAR or VARCHAR
Posted: Wed Jul 02, 2008 4:32 am
by satishbalantrapu
If the string is length is more, say 50 then following can be used
Code: Select all
TrimLeadingTrailing(In.InputColumnName):PadString('','0',50-len(TrimLeadingTrailing(In.InputColumnName)))
Thanks,
Satish
Posted: Wed Jul 02, 2008 5:05 am
by ArndW
Why not just "LEFT(In.InputColumnName:STR('0',50),50)" - simpler and uses somewhat less CPU?
Posted: Fri Jul 04, 2008 3:06 am
by LavanyaRamesh007
ArndW wrote:Why not just "LEFT(In.InputColumnName:STR('0',50),50)" - simpler and uses somewhat less CPU? ...
It woked out. Thanks a lot :D
Posted: Mon Jul 07, 2008 6:04 am
by rajendharreddy
Create a routine with the following code. Call the routine in wherever required.
if Len(In.InputColumnName) = 2 Then Ans = In.InputColumnName:'000'
else if Len(In.InputColumnName) = 3 Then Ans = In.InputColumnName:'00'
else if Len(In.InputColumnName) = 4 Then Ans = In.InputColumnName:'0':
else Ans = In.InputColumnName
Posted: Mon Jul 07, 2008 7:56 am
by OddJob
Yikes, that last solution is absolute madness
What happens when the requirement says pad up to 1000 zeros - your cutting and pasting skills will be seriously tested, and the result will be completely unsupportable!