LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Convert 1D array to 2D when have space between cells

Solved!
Go to solution

Hello guys,

I am receiving the data like that

leandrofeder_1-1712931298859.png

I'm getting the data this way, and I need each empty cell to be added to the next row of the array

As in the image below, as it is now and as it should be

I ask for your help, because I am not able to accomplish this
leandrofeder_0-1712931243483.png

 

0 Kudos
Message 1 of 5
(752 Views)
Solution
Accepted by topic author leandrofeder

@leandrofeder wrote:

... I need each empty cell to be added to the next row of the array

As in the image below, as it is now and as it should be

I ask for your help, because I am not able to accomplish this
leandrofeder_0-1712931243483.png

 


There are many ways how to do this, for example

snippet.png

Message 2 of 5
(735 Views)
Solution
Accepted by topic author leandrofeder

Or if you prefer to have  cycles, then two more variants:

snippet2.png

I'm not sure, may be here kind of "Rube Goldberg Code" or not, but don't see any other ways for further simplification.

 

Message 3 of 5
(707 Views)
Solution
Accepted by topic author leandrofeder

@leandrofeder wrote:

I'm getting the data this way, and I need each empty cell to be added to the next row of the array


It semes you are not adding any empty cells to the next row. You are discarding empty cells and taking them as signal to start a new row.

 

Something is seems wrong with your element 56 in the input array. Would that need special handling?

 

altenbach_0-1712935583694.png

 

If we can assume that the first element is not an empty string, here's a simple explicit solution. (If the first or last element can be an empty string, small tweaks are needed, but that should get you started.)

 

 

altenbach_1-1712936309717.png

 

 

 

Message 4 of 5
(693 Views)

@Andrey_Dmitriev wrote:

There are many ways how to do this, for example


Element at index 56 seems to contain some binary data, so there is a nonzero chance that a random \t  or even double-linefeed could occur, breaking everything downstream.

 


@Andrey_Dmitriev wrote:

Or if you prefer to have  cycles, then two more variants:

...

I'm not sure, may be here kind of "Rube Goldberg Code" or not, but don't see any other ways for further simplification.


I agree that there can still be significant simplification, e.g. no blue data at all! (see my similar code above). I also think that the constant array splitting might be hard on the memory manager, depending how smart the compiler can simplify it or not.

 

More efficient solution can be made, for example if we know the maximum row length beforehand.

0 Kudos
Message 5 of 5
(659 Views)