Six Stars

put decimal point after two digits

Hi all

i have row in csv which has below data  ,i want to insert decimal point after the starting two digits

i am using Tmap 

number1

12355

23455

26463

35535

Expected:

number1

12.35

23.45

26.46

35.53

 

Thnks 

1 ACCEPTED SOLUTION

Accepted Solutions
Employee

Re: put decimal point after two digits

Hi Sushil,

 

     Please add another LEFT function as a quick option to limit the output to first five characters.

 

StringHandling.LEFT(StringHandling.LEFT(row1.input,2)+"."+StringHandling.RIGHT(row1.input,StringHandling.LEN(row1.input)-2),5) 

 

If the solution has helped you, could you please mark the topic as resolved? Kudos are also welcome :-)

 

Warm Regards,

 

Nikhil Thampi

 

 

3 REPLIES
Employee

Re: put decimal point after two digits

Hi,

 

    Please read the value as string to a tmap and use the below function.

 

StringHandling.LEFT(row1.input,2)+"."+StringHandling.RIGHT(row1.input,StringHandling.LEN(row1.input)-2) 

 

Note:- Please add additional checks to handle NULL and strings whose length are less than 2 if required.

image.png

 

 

 

 

Once the conversion is over, you can convert the string to Double if the target is looking for that option.

 

Warm Regards,

 

Nikhil Thampi

 

 

Six Stars

Re: put decimal point after two digits

@nikhilthampi 

Thank you

But you missed limiting to two digits after decimal point.please check my expected output 

 

Employee

Re: put decimal point after two digits

Hi Sushil,

 

     Please add another LEFT function as a quick option to limit the output to first five characters.

 

StringHandling.LEFT(StringHandling.LEFT(row1.input,2)+"."+StringHandling.RIGHT(row1.input,StringHandling.LEN(row1.input)-2),5) 

 

If the solution has helped you, could you please mark the topic as resolved? Kudos are also welcome :-)

 

Warm Regards,

 

Nikhil Thampi