Seeking assistance on converting the output of SPLIT from a substring into an array of integers
The requirement is to create an array of integers like [7,53,57,58] from data that is formatted "7,53,57,58"
Using SPLIT I can create a substring "7","53","57","58" and then pass that to ARRAY to give ["7","53","57","58"] however this is not acceptable because the value must be int(). What is the best way to convert the values from strings to integers inside the array?
Declare a empty array and loop through each member and convert to an int()? Can anyone give advice on this?
Is there no way to work without loops ? Loops are so time consuming.. the whole idea of the split and array is to not have to use a loop
Brilliant Many thanks your solution is spot on.
Here is my understanding of how it works for anyone else who comes this way
Many thanks for your assistance Bof.
Hi @SPOD :
Yes.You need to declare an empty array variable first, then iterate over the results of the split, and finally fill this variable with the int() function.
The solution I provided should fully meet your requirements.
Best Regard,
Bof
The problem with that solution is initial compose input in your example is starting from an array of integers. My data is "7","53","57","58", i'm looking for a method to convert the data into an array of integers because the api I'm working with will not accept the values in quotes. I'm thinking the idea of declaring an empty array and then looping through each member in ["7","53","57","58"] and using INT() to populate the (empty ) initialised array. Will that work or is there a better way?
WarrenBelz
146,524
Most Valuable Professional
RandyHayes
76,287
Super User 2024 Season 1
Pstork1
65,906
Most Valuable Professional