LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Delete Specific columns from array

Solved!
Go to solution

Hello,

 

I am attempting to search for specific headers in an array.  If they are found, I wanted to then delete all the COLUMNS with that specific header.  Can you help me accomplish this?

 

Thanks,

hiNi.

Download All
0 Kudos
Message 1 of 12
(5,611 Views)

Use "Delete From Array" and wire the index into the column terminal:

 

DeleteFromArray.png

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

Sorry, snippets not working.

0 Kudos
Message 3 of 12
(5,596 Views)

I do not think this will work. As you delete columns the index will change, so you will be deleting the wrong column. A small modification should make it work.snip.png

 

 There is probably a better way to do this, maybe like thissnip2.png

 

 

 

I need to head to a talk so I cannot test thoroughly, please verify that it works for you.

 

Cheers,

mcduff

 

 

Message 4 of 12
(5,582 Views)

Just found a problem, need a sort array in the second method, like below.

snip.png

 

 

 

 

0 Kudos
Message 5 of 12
(5,577 Views)
Solution
Accepted by topic author hiNI

Lol, sorry, I only tested it for one column... Yeah the index will change so, actually, I think you need to sort the array of indices, then reverse it.

 

DeleteFromArray.png

 

I don't think that second method works because you are building up the array as rows instead of columns with the auto-indexing.

Message 6 of 12
(5,554 Views)

Hello Mcduff,

 

Your solution does not work.

0 Kudos
Message 7 of 12
(5,547 Views)

Using "delete from array" in a tight loop is cringeworthy and not efficient. For each deleted row, tons of elements need to be reshuffled in memory (note that 2D arrays are stored linearly in memory order, and must be contiguous, so each deletion of a row requires moving most array elements to a new location. In the end most elements have been moved numerous (numerous!!) times!)

 

(See also our NI-Week 2016 presentation)

 

Sometimes it is easier to swap the search and look for the rows to keep. Now we can build a new array with those and simply transpose later. I am sure that's still much more efficient. Here's what I had in mind.

 

 DeleteColumns_CA

Message 8 of 12
(5,517 Views)

@HopeH wrote:

Sorry, snippets not working.


They work if you expand the image and click the download button.  You'll have to go find where it was saved (download folder). 

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 9 of 12
(5,497 Views)
Solution
Accepted by topic author hiNI

So, back to the original code. There is no need for a multiframe state machine and tons of shift registers, controls that are never used (=data in), etc.

 

Here's how it could look like.

 

 ColDelete.png

Message 10 of 12
(5,493 Views)