LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Search 1D array for all instances and add another array.

Solved!
Go to solution

Hello.

 

I am trying to make a program that makes a meal plan and shopping list for the week, from a set of predefined recipes.

The way it works is that I have a excel document with the different recipes, ingredients and how much of each ingredient. Then the program makes a list of X different recipes and combine all the ingredients to a shopping list.

 

So, in the end I have 2 arrays. One being a text array with the name of the ingredient and the other a numerical array with how much of each ingredient.

 

Here is my problem. I would like to delete duplicates on my text array and then add the numbers together on the numerical array. I will try to formulate an example below.

I have one text array with the items eg: [Milk, Flour, Sugar, Milk, Milk, Ketchup] and another with the numbers of how many pieces of the items I want to buy eg: [1, 1, 2, 3, 1, 1].

 

In this example I would like to sum up all the entries of milk, so I would end up with [Milk, Flour, Sugar, Ketchup] and [5, 1, 2, 1]. I hope this makes sense.

0 Kudos
Message 1 of 7
(159 Views)

Hi Marcus,

 

use a LUT (look-up table) based on variant attributes (or a map/set in LV2019).

See here

 

(A very similar question came up recently.)

Best regards,
GerdW
CLAD expired, using LV2011SP1 + LV2017 (+LV2019 sometimes) on Win7+cRIO
Kudos are welcome Smiley Wink

Message 2 of 7
(143 Views)

How will you combine all of the different units of measurement that could be used for recipes and convert that into a store bought unit?  For example, milk is typically measured in cups or mL but it bought in gallons or liters.  If one recipe uses cups and another uses mL, you'll need a conversion factor to be able to combine them.  Just something to consider.

 

Is this a practical application that you plan to use at home or is it a school project? 

aputman
LabVIEW 2017
LabVIEW Programming
0 Kudos
Message 3 of 7
(96 Views)
Solution
Accepted by topic author MarcusNilsen

Hello Marcus,

 

Please find the attached VI that gives you the required solution.I have used a VI from OpenG Library and I have attached it too.

Hope it helps, Let me know if my understanding to your problem is right.

 

Thanks

Rahul

Click KUDOS and Mark as Solution to convey Thanks

 

0 Kudos
Message 4 of 7
(71 Views)

Hey aputman, that is a good point. I think that I will start with getting it to work with just being consistent with my units in my recipe spreadsheet and only using liters for milk and so on. 

 

This is just a fun project for home, but if it comes to work really well then I might use it to do my weekly meal and shopping plan.

0 Kudos
Message 5 of 7
(57 Views)

Hello Rahul.

 

Thank you so much, this does exactly what I asked for. thank you so much!

0 Kudos
Message 6 of 7
(52 Views)

Welcome. 

 

Thanks

Rahul

Hit KUDOS for Thanks

0 Kudos
Message 7 of 7
(44 Views)