Replace and Split Excel value

HI,

when i read excel value in uipath it is not able to read my (Comma)(,) its reading as (Dot)(.)
I have used assign to solv this…
varExcelDotToComma = In_Arg_OI_DT_Payment.ToString().Replace(“.”,“,”)

In_Arg_OI_DT_Payment = 2547,70 and it can be also value 345,45
Now i want that if my Excel value have a (Zero)(0) at the end then I want to remove that… like 2547,7
so i get the 2547,7 amount.
But if the value is 345,45 then i do not need any changes…

It is possiable to create an if statement and use both replace value split together if value have a 0 and also if no Zero.

Remeber if it has no Zero then my (varExcelDotToComma) is prefect right now… But i have to many assign value so its hard to use after in a if statement that which to use :slight_smile:

@Palaniyappan you are expert in split and replace can you help me :slight_smile:

1 Like

Use contains inside a if statement to check if a comma exists and based on the condition, perform the split.

1 Like

I tried with contians, but its giving me alot of error… :frowning:

Here’s how to solve it:

  1. Use a Contains inside an if statement to see if your value contains a dot and if it does, replace it with a comma.
  2. Use a EndsWith inside an if statement to see if your value ends with 0 and if it does, use Remove(yourStringLength - 1, 1) to remove it.
2 Likes

i am not sure about length… its different like… 88,30, 350,30 6748,80 or 12345,45 ect. so how to find that…

1 Like

I have solved this… thanks for tips.

1 Like

Hi @Latif
This would help you if needed in a single expression

str_output = Str_input.ToString.Replace(“,”,”.”).ToString.TrimEnd(Convert.ToChar(“0”))

Cheers @Latif

1 Like

thanks @Palaniyappan i have solved my self like this…
IF(In_Arg_OI_DT_Payment.ToString.Contains(“0”),In_Arg_OI_DT_Payment.ToString.Remove(In_Arg_OI_DT_Payment.ToString.Length -1,1),In_Arg_OI_DT_Payment.ToString().Replace(“.”,“,”))

do tell if i did correct or wrong…
I find if value have 0 there i remove that and then i do a simple replace “.” in to Comma

Look my assign value is not 100% correct… Can someone explain me…

,In_Arg_OI_DT_Payment.ToString().Replace(“.”,“,”))

In_Arg_OI_DT_Payment value is coming from Excel and value can be like
In_Arg_OI_DT_Payment = 193.30 or 1345,34 or 12.64 or 18,09 or any kind of number

I want that if i have 0 at the end then it shoudl remove that 0 and show me only 193,9 or if it is a normal value like 1345,34 or 12.64 then do nothing.
plus as excel value is showing me as a Dot (.) value so in the end of that IF statement Im replacing Dot to comma.
I created this to solve that…

IF(In_Arg_OI_DT_Payment.ToString.Contains(“0”),In_Arg_OI_DT_Payment.ToString.Remove(In_Arg_OI_DT_Payment.ToString.Length -1,1),In_Arg_OI_DT_Payment.ToString().Replace(“.”,“,”))

It’s working but some time i noticed it’s removing the last digit which is not 0 like 18,09…it has removed 9 and gave me 18,0 as excel value. which is wrong and it should give me 18.09…

Can anyone tell me WHY or help?

It’s because you’re using Contains to check for 0. Instead, use EndsWith to check for 0 and if it does, remove it as demonstrated here:

Thanks @monsieurrahul i changed it to EndsWith and it’s working perfect… thanks a lot…

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.