07-27-2015 08:05 AM
How to programmably delete all empty column in 2 dimensional array
07-27-2015 08:18 AM
For each column
If column NOT empty
Include in output array
Use the CONDITIONAL option on the output tunnel.
Blog for (mostly LabVIEW) programmers: Tips And Tricks
07-27-2015 08:56 AM - edited 07-27-2015 08:58 AM
Here's a postage stamp code using OpenG.
EDIT: Made by own Rube. Instead of OpenG and is empty array, you can use the Empty String/Path primative, and the And array Elements.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
16 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
07-27-2015 09:03 AM
Note that you cannot have a truly empty column in an array. You can have a column with all default values for the element datatype. This is what the previous responses have shown.
Lynn
07-27-2015 10:20 AM
Here is a solution that I think will work for me.
Based on Coastel's logic
07-27-2015 10:26 AM - edited 07-27-2015 10:28 AM
@quexin wrote:
Here is a solution that I think will work for me.
Based on Coastel's logic
Yeah that won't work at all. In LabVIEW arrays have the same number of rows in all columns, and the same number of columns in all rows. If you index out a column (like you are) it will always be the same size as all the other columns, so if one is empty they all are empty, if one of them is not empty, then all of them will not be empty.
There is also some Rube-like code because if you want to index columns just use the transpose like I showed, and use indexing terminals going into the for loop. If you want to know the number of rows and columns, you can also use the Matrix Size instead of size and index, and did you mean to run the loop one minus the number of rows, but index columns? Oh and what is with the case structure? If True make false if false make true? Just remove the case structure.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
16 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
07-27-2015 10:34 AM - edited 07-27-2015 10:35 AM
If you think it will work, you should try running it before posting it. Then you'll find out it doesn't work at all.
First you have a Rube Goldberg in there that the True and False cases are identical. Second, your "Is Empty" won't work because your array isn't empty. It is a column full of empty strings, but the the column itself isn't empty.
This is what will work with a lot less code.
07-27-2015 10:38 AM
First of all, you have to define what "empty" means.
As johnsold said, there really is no such thing.
If the column exists, then it is not empty. Period.
You might mean "contains only zeroes", or "contains only blank strings", but that's not the same thing as "empty".
Don't even TRY to write code until you define in your head what you mean by "empty".
So, my code works:
For each column
If column NOT empty
Include in output array
Blog for (mostly LabVIEW) programmers: Tips And Tricks
07-27-2015 10:41 AM
I wonder if this is an example of Cunningham's Law.
"The best way to get the right answer on the Internet is not to ask a question, it's to post the wrong answer."
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
16 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
07-27-2015 11:01 AM
The best way to delete empty columns is to not generate empty columns.
What part of your code generates this 2D array?