cancel
Showing results for 
Search instead for 
Did you mean: 

Convert list of string to list of numbers

shefali
Deputy Chef I
Deputy Chef I

Is there a formula that can be used to convert list of String variables to a list of integers ? 

 

I/P is ["1","100","50", "4"] 
O/P [1,100,50,4]

1 ACCEPTED SOLUTION

Hi @shefali,
If you observe my screenshots:

1️⃣ In the 2nd and 3rd images,
I used Variable_name: List and Datatype: String. When applying the pluck("v") formula, it automatically converts to List_of_Numbers, so there's no need to explicitly set the data type as List.

2️⃣ I have a small curiosity: Why do we need to create two variables with Integer or Number data types to parse a number list?
Answer: There's no need to use two variables. As I suggested, when we apply the pluck("v") formula, it automatically takes care of converting to List_of_Numbers.

3️⃣ However, when using list functions, it still treats the variable as a list. Shouldn't it actually be recognized as a number instead?
Could you please share a screenshot? I didn’t fully understand your point here.

Looking forward to your insights! 😊

Thanks and Regards,
Shivakumar K A

View solution in original post

20 REPLIES 20

Hi Shivakumara,

Thanks for the response. The function you've used appears to return a string variable containing integers. However, I need to first extract a list of integers. Then, I can use existing list functions to determine the minimum and maximum values from the list.

I am able to perform this operation on a list of numeric strings. However, the issue is that the min and max functions are returning values based on ASCII character order rather than numerical values.

If you feel there is an alternate way to handle this using existing functions, please guide me 

Hi @shefali ,
I found another way doing it is 
1. when the input is "List of String" pass it to another variable where it should of data type "Integer"
2. Workato will take care of your "List_of_String" to "List_of_Integer"
3. Apply formulae "MAX" or "MIN" whichever you needed as per your requirement

Here are some screenshots for your reference:
Lst_string_1.PNG

List_string_2.PNG

List_string_to_int_1.PNGList_string_to_int_2.PNGList_string_to_int_MAX.PNG

Thanks @shivakumara

Happy to help.  @Prudvi  🤗

HI Shiva, 

 

I tried passing a list of string to a new variable of type integer. O/P is still a list of string. The auto -conversion is not working for me. 

 

 
 

1.jpg2.jpg