Need to convert scraped string into double, the number is in German format

Hi

I have a situation where I am scraping data from SAP (German Client) and when I download the amount it is like 98.765,78 I need to convert this to double so that this is necessary for other calculations.

I have tried these options to display in the log message

Double.Parse(str_Currency).ToString

Double.Parse(str_Currency,0).ToString

I get the following error

Log Message: Input string was not in a correct format.

Regards,
Manjesh

Firstly you have to swap the dot with comma after that you can use Convert.ToDouble method
InProperString = 98.765,78
ProperString= 98,765.78
Convert.ToDouble(ProperString)

hi @manjesh_kumar

check this example

hope it helps
test.xaml (6.8 KB)

best regards!

1 Like

Hi @manjesh_kumar ,

Here is a sequence I have developed based on a similar thread which discusses this problem:

image

Basically, you have to play around with the CultureInfo to get what you want.
In this scenario, you are dealing with Portugal Numbers, so you have to implicitly specify what the formats are before referencing the Culture Info.

For that, first create a variable of type System.Globalization.CultureInfo and initialize it using this →

New CultureInfo("pt-PT")

Next, use two assign activity like so:

cul_info.NumberFormat.NumberGroupSeparator = "."
cul_info.NumberFormat.NumberDecimalSeparator =","

This tells the robot all it needs to know about how to go about processing the given string.

After that is done, all that is left is to convert our string to Double →

Convert.ToDouble("98.765,78",cul_info)

ConvertDoubleFromPortugal.xaml (6.4 KB)

Kind Regards,
Ashwin A.K

1 Like

Thank you very much

1 Like

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