09-18-2015 08:47 AM
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.
Solved! Go to Solution.
09-18-2015 08:51 AM - edited 09-18-2015 08:53 AM
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> ---'
09-18-2015 08:53 AM
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! 😄
09-18-2015 08:58 AM
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.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
09-18-2015 09:02 AM - edited 09-18-2015 09:03 AM
Gosh, it must be early... I went and did all the work for you. What was I thinking... might as well post it.
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> ---'