LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to classification from 1D array to 2D array by key word

Hi
I am a array classification question..
Now i have 1D string array, and need to classification to 2D Array and the "A" is first in every row, like as below picture, how to do it?
Thanks

 

WIILE_1-1714060621127.png

 

 

0 Kudos
Message 1 of 6
(145 Views)

Use "reshape array" to 3x3.

 

altenbach_0-1714061273364.png

It is not clear what you mean by keyword. please explain if the input can be more complicated (e.g. if the A's are not equally spaced or if the length of the input array can vary)

0 Kudos
Message 2 of 6
(140 Views)

Use Reshape Array from the Array pallette. You can drag the lower part to add more dimensions.

snip.png

0 Kudos
Message 3 of 6
(138 Views)

Thanks for your reply,
It no clear for previous description, below is detail:


The 1D Array data as below:

WIILE_1-1714062953707.png

The target is 2D Array and the first data in the row is "A"

The judgment method I came up with is to use a for loop to retrieve data from a 1D array one at a time and then determine if it is "A", thus categorizing it. However, I am not sure how to proceed.

 

WIILE_0-1714062938401.png

 

0 Kudos
Message 4 of 6
(110 Views)

OK, so your spaces between the "A" vary in the number of elements and reshaping will thus not work. LabVIEW does not support "ragged" 2D arrays, so the rows would need to be padded with e.g. empty strings to the longest entry.

(You can do ragged array by having a 1D array of clusters where the element is a 1D array representing a column).

 

In any case, splitting by "A" seems easy enough. I'll whip something up.

0 Kudos
Message 5 of 6
(96 Views)

Here's a quick draft how it could be done.

(another option would be to use "search array", for example)

 

Might need tweaks if the first element of the input is not a Key or if it ends in a Key, depending on the desired behavior in these cases.

 

altenbach_0-1714070265835.png

 

0 Kudos
Message 6 of 6
(90 Views)