LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

split and group string

Solved!
Go to solution

i want to split and group string into array..for example i want 4 group which is array1,array2,array3 and array4

and then if i write 1111 0010 it will go into my array1 and 0010 will be my value under it

then if i write 2222 0011 it will go into my array2 and 0011 will be my value under it and so on for array3 and array4

simplify it i write 1111 0010 2222 0011 3333 0012 4444 0013 my array will look likes this

 

array1  array2  array3  array4

0010    0011    0012    0013

 

if other than 1111,2222,3333,and 4444 i want to ignore it and it's value

can someone give me example on this

0 Kudos
Message 1 of 20
(5,602 Views)

Is that delimiter a space between the groups of 4 numbers?

 

In this case, use "spreadsheet string to array" with space as delimiter and a 1D string array as type, reshape the array to 2 columns, autoindex into a FOR loop and index the two elements. wire the first element to a case sturcture with a default case and the other case for 1111, 2222, 3333, 4444. Build the second element into an output array in the latter case, while skipping the default case. 

0 Kudos
Message 2 of 20
(5,598 Views)

Here's a quick example...

 

As I said, the other case is "default" and has the string array wired across unchanged.

 

0 Kudos
Message 3 of 20
(5,592 Views)

how to change the output if i want it to be sort in 2d array..means i have 4 column for my element which is 1111,2222,3333,4444

it nice if u can attach the vi too

0 Kudos
Message 4 of 20
(5,588 Views)

 


@icycool wrote:

how to change the output if i want it to be sort in 2d array..means i have 4 column for my element which is 1111,2222,3333,4444

it nice if u can attach the vi too


This makes no sense. You need to describe the problem better.

 

0 Kudos
Message 5 of 20
(5,586 Views)

what i mean is i want to create a 4 column table for my output which looks like this

 

array1 | array2 | array3 | array4 |

0010   | 0011   | 0012   | 0013   |

          |           |           |           |

          |           |           |           |

 

array1 = 1111, array2 = 2222, array3 = 3333, array4 = 4444

0 Kudos
Message 6 of 20
(5,581 Views)

Do all elements occur with the same frequency? You can only have a 2D array like this if all columns have the same length at the end. Do they?

 

In general you could build 4 different 1D arrays. Add four cases to the case structure, one for 111, 222, 333, and 444 and build the four columns independently. Assemble the 2D array later, after the FOR loop. See how far you get.... 

0 Kudos
Message 7 of 20
(5,578 Views)

oh i see..i've thinking about using four case structure like u said before but dont know how to do it..can u show me how it been done?

0 Kudos
Message 8 of 20
(5,574 Views)

No, only one case structure! However, instead of the default case and the single case of the earlier example, you would instead have 5 cases in the case structure. name them 1111, 2222, 3333, and 4444 and a default case. (to add more cases to a case structure, right-click...add case after...)

 

Now use 4 shift registers and wire them across all cases. In the 1111 case, add elements to the first array, in the 2222 case, add elements to the second array, etc. Once the loop is finished, use "built array" to make the 2D array out of the 4 1D arays, then transpose it. Note that if any array is shorter than the rest, it will be padded with empty strings.

 

These are just minor changes to my example above, so try to do it yourself. Good luck!

 

How big are your arrays?

 

(There are many other ways to do this, of course). 

 

 

0 Kudos
Message 9 of 20
(5,568 Views)

haha yes i know..just want to say 4 case actually..btw can u attach ur example vi.

i'll try to change it as u said..thanks

0 Kudos
Message 10 of 20
(5,562 Views)