LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

remove duplicates from pull-down boxes

I have a series of pull-down boxes that read from columns in a 2d array using producer-consumer architecture. There is potential that I append new data to this array multiple times a day (via writing to a .txt file and this vi will read the .txt file), and thus will get duplicate values in the columns. This happens because a couple of the columns contain dates for values. I am looking to remove duplicate data from the pull-down displays, but not delete the data. I've found this thread and I like the potential for plugging it in as a subVI, but it isn't quite what I'm looking for and it deletes data from the 2d array. Thanks in advance.

0 Kudos
Message 1 of 3
(2,188 Views)

I figured it out. I was way overthinking how to do this. Attached is what I've created. It could be simplified so that rather than indexing the 2D array, you can add a For Loop and autoindex.

0 Kudos
Message 2 of 3
(2,170 Views)

 


@csmrunman wrote:

It could be simplified so that rather than indexing the 2D array, you can add a For Loop and autoindex.


 

No, you cannot unless you can guarantee that all output arrays have the same lenght. In general, each row can have a different number of duplicates. You would need to e.g. bundle each output array before indexing the results at the output tunnel.

 

For small problems such as this, the code is probably OK. For huge arrays, it will not scale very well, because searching is linear with the array size, and it need to be repeated for every elements (O(N²)). Then you are constantly resizing the output arrays, hammering the memory allocations.

 

Does the final order of the elements matter? If you are allowed to sort the arrays first, there would be much more efficient algorithms that operate mostly in place.

 

Attached is a quick draft, comparing two algorithms.

0 Kudos
Message 3 of 3
(2,165 Views)