05-31-2022 09:29 AM
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!!
Solved! Go to Solution.
05-31-2022 10:10 AM
@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?
05-31-2022 10:21 AM
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:
Results in:
With a map it would be much easier:
05-31-2022 03:14 PM
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)
05-31-2022 06:06 PM
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!!
05-31-2022 07:11 PM
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.
06-01-2022 03:30 AM
@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.
06-01-2022 09:30 AM - edited 06-01-2022 10:07 AM
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. 😄
06-01-2022 09:45 AM
@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.