Page 1 of 1

Shifting and Truncating

Posted: Thu Jul 19, 2018 11:54 am
by chakkara
Hi folks,

I have an input file which has 5 digit chars.

My requirement is to pad a character at the left most position and truncate the right most one. kindly suggest how to achieve this

Ex :

Input

1,ABCDE

Output:

1,SABCD
1,SSABC
1,SSSAB
1,SSSSA
1,SSSSS

Posted: Thu Jul 19, 2018 3:26 pm
by chulett
What have you tried so far, anything? Seems to me a combination of transformer looping, substring via 'left' and simple concatenation would do the trick. Lather, rinse, repeat.

Posted: Sat Jul 21, 2018 4:46 am
by ray.wurlod
I agree with Craig. Try it, and let is know how you go. Assuming you are using a counted loop, loop while @ITERATION <= 5

Posted: Mon Jul 23, 2018 12:22 pm
by UCDI
a mix of substring operations should get you there, eg
newvalue = left(oldvalue, 2):'S':right(oldvalue,4)
newvalue2 = left(oldvalue, 2):'SS':right(oldvalue,3)
..etc

do that in a stage variable is one way, eg if you wanted each value in a new column.

use a loop if you wanted each one as a new record.