LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

remove duplicate elements of a cluster

Solved!
Go to solution

I have a cluster of elements that consists of the following information:

column 1: String of user names     column 2: Numeric of times

EX:

 

Doe, John    65

Doe, Jane    45

Doe, Jane    55

Doe, Jim      35

Doe, Jim      20

Doe, Jim      75

 

What I am trying to do is turn that into the following:

Doe, John    65

Doe, Jane   100

Doe, Jim      130

 

Please advise.

0 Kudos
Message 1 of 5
(4,141 Views)

Is this a cluster, or an array? You say cluster, but then you say "column".

 

What you're doing isn't removing duplicates, you're finding duplicate items from the first elements and combining the corresponding second elements.

 

If it's a cluster, use a For loop to unbundle all of the Names and Times. Once you have an array of all Names and an array of all Times, search the Names array for each unique name and add the corresponding indices from the Times array together. The OpenG add-on for LabVIEW is great for this kind of array operation.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 2 of 5
(4,136 Views)

Hi Newer,

 

- You cannot remove elements from a cluster without modifying the cluster datatype…

- You can remove elements of arrays!

- You need to sort your elements, then compare with previous element to check for new/same name and sum as needed…

 

What have you done so far?

Where are you stuck?

It's a nice example to learn LabVIEW! 😄

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 3 of 5
(4,131 Views)

Yeah on top of what the others have said this isn't even a find a remove duplicates from an array, because you are summing the "Number of Times" for a given match of first and last name.  For loop and shift register going through each element in the array, adding to the previously matched name will do what you want.

0 Kudos
Message 4 of 5
(4,122 Views)
Solution

Gosh, it must be early... I went and did all the work for you. What was I thinking... might as well post it.

 

Example_VI_BD.png

The "ogtk" VIs are from the OpenG palette, which can be installed using the VI Package Manager.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


Message 5 of 5
(4,115 Views)