Issue with conversion from string to double - double

I am not able to convert my string to double.I am getting below error
conversion from string to double is not valid
I have tried below approach but all are giving me same error. I am using Assign activity in uipath with intvalue defined as double and row.Item("TaxResult") retrieves the value from excel
intval = Val(row.Item("Tax Result").ToString.Trim)
intVal = Double.Parse(row.Item("Tax Result").ToString.Trim , double)
intVal = cDbl(row.Item("Tax Result").ToString.Trim)
Out of the above three first one is returning to me 0 value while the below two is giving me an error
"conversion from string to double is not valid"
Tax Result column in excel stores the value like (5.2, 19.8, 98.87). I want to sum all these value as part of my requirement

First, you don't need the .Item after row, it should just be row("Tax Result")
Ideally you should use a Double.TryParse() to try and avoid any exceptions if it cant convert to Double.
This can be achieved using an If Statement as seen below, if the Try Parse is successful the string can be converted using Double.Parse(row("Tax Result").ToString.Trim) and on failure I have assigned intval to 0 but you could put handling here to handle if it can't convert the number

Related

How do I parse out a number from this returned XML string in python?

I have the following string:
{\"Id\":\"135\",\"Type\":0}
The number in the Id field will vary, but will always be an integer with no comma separator. I'm not sure how to get just that value from that string given that it's string data type and not real "XML". I was toying with the replace() function, but the special characters are making it more complex than it seems it needs to be.
is there a way to convert that to XML or something that I can reference the Id value directly?
Maybe use a regular expression, e.g.
import re
txt = "{\"Id\":\"135\",\"Type\":0}"
x = re.search('"Id":"([0-9]+)"', txt)
if x:
print(x.group(1))
gives
135
It is assumed here that the ids are numeric and consist of at least one digit.
Non-regex answer as you asked
\" is an escape sequence in python.
So if {\"Id\":\"135\",\"Type\":0} is a raw string and if you put it into a python variable like
a = '{\"Id\":\"135\",\"Type\":0}'
gives
>>> a
'{"Id":"135","Type":0}'
OR
If the above string is python string which has \" which is already escaped, then do a.replace("\\","") which will give you the string without \.
Now just load this string into a dict and access element Id like below.
import json
d = json.loads(a)
d['Id']
Output :
135

SSRS nested IIF/CStr explanation

Could someone let me know if the IIF statement below means output any value that starts with a 4 please?
=IIF(LEFT(CStr(Fields!CLOCK_NUMBER.Value),1)="4",Fields!JOB_NO.Value, "")
The short answer is yes.
Starting from the middle and working outwards this expression is doing the following..
Get the value of the field CLOCK_NUMBER
Convert this to a string (the CSTR function)
Take the 1st character (LEFT function with 1 as the seconds parameter)
If the equals "4" return the Value that is in JOB_NO
Otherwise return an empty string
If this is not working for some reason, try converting the job_no to a string before returning, that way you ensure you always return a string (in case JOB_NO is numeric). You can simply wrap the job_no in a CSTR like this CSTR(Fields!JOB_NO.Value)
Translates to..."try to" convert the field CLOCK_NUMBERS's native value to a string and take the LEFT(1) most significant digit(s) and if that value is "4" then return the JOB_NO Fields's value. else return empty string.
So, it is, if the first digit is 4 then return JOB_NO.

How to represent large number without the E form in Scala

I deal with numbers of this form 1.446267186999E7 and i want to represent them without E.
For example 1.446267186999E7 i want it to be 14462671.86999 .
How do i convert it to this form without getting the :
error: integer number too large.
Thanks for the helpers.
Try this:
BigDecimal(1.446267186999E7).toString
The BigDecimal.toString method will give you the string representation of the number in decimal form.
That is just a formatting problem if you store it as a double.
import java.text.DecimalFormat
val d: Double = 1.446267186999E7
val decimalFormat: DecimalFormat = new DecimalFormat("0.#####")
println(decimalFormat.format(d))
should give you 14462671.86999
You probably after BigDecimal. In terms of string formatting, look at the .format method, or printf

How to check if value in field is decimal and not string (DATASTAGE)?

How to check if value in field is decimal and not string (DATASTAGE) ?
I am using with Datastage Version 8.
Try using IsValid() with the 'decimal' sub-type on the incoming string.
If IsValid("decimal" , in.value_string ) Then in.value_tring Else SetNull()
You can use Alpha & num function inside transformer which gives you whether the given value contains only alphabets.
If alpha(column) is 1 then its purely alphabetical.
Else check if Num(column) is 1, if this true then it is purely a number.
Reference to official doc-https://www.ibm.com/support/knowledgecenter/SSZJPZ_11.5.0/com.ibm.swg.im.iis.ft.usage.doc/topics/r_deeref_String_Functions.html

PARI:similar function like Integer.parseInt()

I want to convert the text hello to ascii decimal in PARI/GP. After that I will
concatenate the values.
I initialize a Vecsmall(hello), after that I run a loop to concatenate the ascii decimal values,
I want to use this concatenated value to * by certain values. The value is now in String type, In Java, there is a Integer.parseInt() to convert the string to int. I wonder if there is a similar function in PARI/GP?
v=Vecsmall("hello");'
for (i = 1, length(v), text=Str(text,v[i]););
//is there any similar function like Integer.praseInt(text) in PARI?
You can use eval
eval(text)
or else a combination of Vecsmall and fromdigits which is faster:
fromdigits(apply(n->n-49, Vec(text)))