Input String was not in correct format error

Dear Members ,

I am trying to convert a column having integer values into double but getting following errors.
Tha name of the column is New cases (1 day*)

Convert.ToDouble(CurrentRow(“New cases (1 day*)”).ToString)

What’s the error message?

Also did you try Convert.ToDouble(CurrentRow(“New cases (1 day*)”)) ?

The error message is Input string was not in correct format

I am using a data table where the column name is New cases (1 day*) .

What’s the value in CurrentRow(“New cases (1 day*)”)?

Try using

Convert.ToDouble(StringVariable, CultureInfo.InvariantCulture)

as mentioned here: c# - Convert string to double: input string was not in a correct format - Stack Overflow

or try

Double.TryParse method

As mentioned here: Double.TryParse Method (System) | Microsoft Docs
Yous should use Double.TryParse because Convert.ToDouble gives error if input is pure string. I tried Convert.ToDouble(“one”) and I got same error like you. So if you are not sure what’s the value in your current row item, go for Double.TryParse


These are my column names 1)Total case,2) New cases(1 day*) 3)New cases(last 60 days). I am using a data table to extract the values of these column names

ok. Please use the method Double.TryParse as I mentioned in my previous post.

Because your row values are not always numbers. It can sometimes be a pure string like “No Data”. Convert.ToDouble throws exception when it doesn’t find numbers in its argument

I am getting error using Parse method

Can you please give me the exact command you wrote and also the exact error message?

I used invoke code activity like this in below screenshot:

So when I gave an actual number in StringVar1 like “1.2”, the boolean output SuccessOrNot is true and the double value is available in the variable “DoubleNumber”

Similarly when I gave StringVar1 like “one”, the boolean output SuccessOrNot is false and therefore we shouldn’t consider output DoubleNumber in this case.

If you use same kind of code, pass CurrentRow(“YourColumnName”) instead of StringVar1. As you have SuccessOrNot boolean variable, use if condition to check the conversion is successful or not. Based on that you can make use of the result and move on to the next row.

Hope this helps you. Let me know if you are still facing any challenges at any step

Thanks a lot for your help. Let me try by following your steps.

1 Like

Hi Surya,

In the below screenshot column some places there are integer values and some places it is mentioned No Data. What value should we replace with 'No Data ’ while converting from string to integer.

I am trying to do by this way INT(CurrentRow(“New cases (1 day*)”).ToString.Replace(“No data”,“0”)) but getting the entire column value as 0.

Kindly can you write the code using double parse. My column name is New cases (1 day*) also there are some values like ‘No Data’.

Don’t replace anything.

Just use the same code as I gave in the invoke code screenshot(refer my previous reply). In the arguments , in the place of StringVar1 Value field give

CurrentRow(“New cases(1 day*”).tostring()

After that activity use an if condition. if(SuccessOrNot) then make use of the result DoubleNumber variable(this variable has your converted double value). There’s no need to write anything in else block

Is this way you are asking Double.TryParse(CurrentRow(“New cases(1 day*”)).tostring()

No need to write as such in that command. Please check my previous reply (Input String was not in correct format error - #10 by Surya_Narayana_Korivipadu) carefully.

Use invoke code activity. Write the code I gave in previous screenshots. Click on edit arguments button in the invoke code activity and write same arguments as I gave in screesnhot except one value.

I’m again highlighting that value in the screenshot. In the position, instead of StringVar1, write
CurrentRow(“New cases(1 day*)”).tostring()

Kindly help me . I am getting so many errors.


You have to create these variables as mentioned by @Surya_Narayana_Korivipadu

@dutta.marina

Share the excel file.