LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

2D string Deleted Duplicated data and get last data

Solved!
Go to solution

Hi all,

Sort out 2D data get test time, I tried add serial number bundle can find out duplicated data in which element, only keep last test time data, how to delete the rest duplicpated,thanks!!

 

Screenshot.png

 

 

0 Kudos
Message 1 of 9
(1,733 Views)

@Sam.Huang wrote:

Sort out 2D data get test time, I tried add serial number bundle can find out duplicated data in which element, only keep last test time data, how to delete the rest duplicpated,thanks!!


I think there's a language barrier here. That's hard to understand.

 

You want to get all test times? Then get duplicate test times? And keep the latest?

 

So get the last 1, the last 2, the last 3, etc?

 

I don't see how a serial nr comes in? Do you mean the array index?

 

Maybe you can give an example on what the output should be, optionally why?

0 Kudos
Message 2 of 9
(1,721 Views)

If I understand correctly, you could use a map with times vs last index.

 

However, you're posting a LV16 VI, and LV16 doesn't have maps.

 

If you have LV20 or up, you would have maps...

 

This:

Last time index.png

 

Results in:

wiebeCARYA_0-1654010385735.png

With a map it would be much easier:

wiebeCARYA_1-1654010492745.png

 

0 Kudos
Message 3 of 9
(1,716 Views)

I agree that your problem description is not clear at all.

 

Since you have all unique items (First column), each has only one test time (second column), which is also the last.

 

Can you manually create an output array of what end result you are expecting from the procedure given the default data in the control? (I assume a 2D array with the same header and same number of columns, just with fewer rows)

0 Kudos
Message 4 of 9
(1,689 Views)

Sorry for not clarifying this question, I just want to sort this array to remove duplicate rows of data and get the last data as screenshot, thanks for your in advance!!

 

screenshot.png

 

0 Kudos
Message 5 of 9
(1,677 Views)
Solution
Accepted by topic author Sam.Huang

Assuming the times are small numbers greater that zero and that there is a text header that you want to keep, here's one possible solution (I guess since you are using LabVIEW 2016, you don't have maps).

 

It would be easy to expand it for fewer assumptions.

 

 

altenbach_0-1654042093328.png

 

0 Kudos
Message 6 of 9
(1,668 Views)

@altenbach wrote:

Assuming the times are small numbers greater that zero and that there is a text header that you want to keep, here's one possible solution (I guess since you are using LabVIEW 2016, you don't have maps).


That also assumes the first number is 1 and the numbers are continuous between 1 and max?

 

Bottom line is that it's hard to make something, not knowing the logic behind it all.

 

Filtering on unique test time, and then use the latest (also time?) could be exactly what you want, but it doesn't make much sense to me.

0 Kudos
Message 7 of 9
(1,642 Views)

wiebe@CARYA wrote:
That also assumes the first number is 1 and the numbers are continuous between 1 and max?

 


 

No, unused time numbers will remain at -1 and get discarded (that's why I initialize the array with -1).

The header will translate to 0 and will not get overwritten.

 

Even with a map (I32->I32, <or maybe more bits if needed), we would just process the numeric fields, but now the time values can be sparse. We still would conditionally index into the raw array to get the remaining rows as in the last part of my code. Searching the ever-growing array gets expensive for large datasets (O(N²). And even without a map there are more competitive ways, e.g. by inserting into the array to keep it sorted and substituting a binary search (O(NlogN) as I outlined in my 2019 NI Week talk, slides 24-29 here). I assume the datasets here are small, so none of this really matters. 😄

0 Kudos
Message 8 of 9
(1,629 Views)

@altenbach wrote:

wiebe@CARYA wrote:
That also assumes the first number is 1 and the numbers are continuous between 1 and max?

No, unused time numbers will remain at -1 and get discarded (that's why I initialize the array with -1).

The header will translate to 0 and will not get overwritten.)


Ah. Duh.

0 Kudos
Message 9 of 9
(1,622 Views)