08-10-2023 03:08 AM
Hallo all,
I had a doubt regarding the conversion of string into a 2D array. I have the following String
I want to seperate this string into a table in which the data before the ``:`` will be in 1 row and data after in another row. I am attaching the programme below. Can someone suggest the changes i need to make in order to do so.
Regards
Speedy
Solved! Go to Solution.
08-10-2023 03:49 AM - edited 08-10-2023 03:51 AM
Hi Indian,
@Speedyindian1 wrote:
I want to seperate this string into a table in which the data before the ``:`` will be in 1 row and data after in another row. I am attaching the programme below. Can someone suggest the changes i need to make in order to do so.
What is your "doubt"? I guess you talk about a "problem"…
So the items in the string should be transposed when converting to 2D array as you want the "labels" in one row and the "values" in another row?
Why do you think you need a loop? (I didn't include the transposing part intentionally…)
08-10-2023 03:51 AM
Take a look at "String to Array" in openG
08-10-2023 04:12 AM
@nitad54449 wrote:
Take a look at "String to Array" in openG
Not everyone has openG - although, outside of licensing requirements for commercial use, I can't imagine why they wouldn't...
08-10-2023 04:30 AM
Hi Gerd,
Thank you for your reply. This works well. I had another doubt regarding the searching of a particular element, for ex: I need to search for customer name (first row) in the table and display the customer name (second row) as output. As there is no option to search in a 2d array, should i split the array and then do the search? can you help me regarding the same?
Regards
Speedy
08-10-2023 04:51 AM
Hi Indian,
@Speedyindian1 wrote:
I need to search for customer name (first row) in the table and display the customer name (second row) as output.
Search the item in the first row data, then use the found index to index the element from 2nd row…
@Speedyindian1 wrote:
As there is no option to search in a 2d array, should i split the array and then do the search?
Why do you want to "split" a 2D array? Why not just index the rows using IndexArray?
08-10-2023 07:32 AM - edited 08-10-2023 07:36 AM
Not mentioned here, but you probably should use a couple of FOR loops to Trim Whitespace from the array elements. This will make the searches a lot easier on you.
After that, Index Array can be used to pull out the two columns. Search 1D Array to find the row for the Customer Name, and then another Index Array to pull out the value associated with the customer name.