LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Delete Array Duplicate for only one column

Solved!
Go to solution

Altenbach,

 

Genius. I built the vi and it worked like a charm. I don't believe I would have been able to do that on my own.

 

Thank you!

 

Ryan

SJ

 

0 Kudos
Message 21 of 29
(1,100 Views)

SimpleJack wrote:

Genius. I built the vi and it worked like a charm. I don't believe I would have been able to do that on my own.



'glad it works for you. Do you mean you built if from scratch?? (That would have been a good exercise, of course. :D)

 

As you might not know, my images attached above are LabVIEW snippets and will turn into fully functional code once inserted into a diagram if your LabVIEW version is new enough. If you have an older LabVIEW version, just ask and we will attach a downconverted VI.

 

Good luck with the programming! 😄

0 Kudos
Message 22 of 29
(1,085 Views)

Hmmm.. I didn't know that. Yeah, I built it from scratch...haha. I have Labview 9.0.1.

 

I think you built it in Labview 10 so I probably can't open it. The only question I have really (and I assumed this was correct) that the "False" case of the case structure is this:

 

 

test.PNG

0 Kudos
Message 23 of 29
(1,078 Views)

LabVIEW 9 was the first (?) version that can create snippets, but my snippets are in version 2010, so they would not work for you.

 

And yes, the false case is just wired across. I should have mentioned that.

 

Here's my version 4 and the benchmark version comparing mine and Darin's, both in LabVIEW 9. The benchmark version is very rough, because you need to re-run it whenever you change any of the controls.

Download All
0 Kudos
Message 24 of 29
(1,072 Views)

Hey,

Sorry to bring up an old thread but I am trying to take this one step further. Besides removing the duplicate, I also need to add the duplicates together and show them in the list. Please look at my attachment. As you can see avocado is on the list twice. Once for a whole avocado, and once for a quarter. I need to remove the quarter of the avocado from the list and add it to the 1 whole avocado (turning it to 1.25 avocado). The list changes all the time, the food items are always on the right, each specific food has the same measurement value in the middle and the quantity is on the left (which needs to be added together when there are duplicates. I am using LabView 15.0

 

0 Kudos
Message 25 of 29
(899 Views)

Seems simple. What have you tried so far?

 

(Also, attach your VI with the default data shown so we have something to play with. If we need to start from scratch, it is less likely that somebody will help.)

 

It is also not clear how to handle a situation where the units don't match. For example, what should happen if you have a cup of salsa and a tbsp of salsa)

0 Kudos
Message 26 of 29
(889 Views)

So when writing code, I am very use to doing this with C++ and Java. I cant seem to wrap my head around it when it comes to LabView. To just remove the line I tried doing a for loop inside a for loop accessing the 2D array in the first loop and accessing it again in the second. Within the second loop I would use the search array function to find the element and using the case structure to remove the element. This did not seem to work because the count starts at one every time. I can see from the code you posted earlier I should of used a shift register and initialize a new array. So far I just ended up using the code from earlier in the posts.

Now, to update the value of "avocado", the program will need to recall what the original value of avocado was. I am not sure on how to do that. But I am assuming that its going to have to be done inside the case structure (see picture), turned into a number from a string, added, and then turned back into a string and put back into that spot of the array.

 

I will make sure the units will always match. For instance, if a cup of something is needed, and the units are in tbs, I will provide how ever many tbs to equal a cup.

 

I attached the code

Download All
0 Kudos
Message 27 of 29
(887 Views)

Your current code assumes that the array is sorted by the last column, and that wasn't true for your first post.

I would probably use variant attributes. Very efficient and flexible and does not require a sorted input. See if you understand it.

(you might want to define the number of decimal digits when converting the DBL back to a string. Not shown))

 

(if you start mixing units for the same item, more code is of course necessary)

 

combinator.png

0 Kudos
Message 28 of 29
(882 Views)

Thank You!

 

It worked wonders!

0 Kudos
Message 29 of 29
(874 Views)