Sorting CSV (excel) with C++

I am just getting into working with C++ and want to write a program that can use an excel file (or .csv) file to sort data. The csv is just a general example.

I used 4 columns. Food name, type of food, weight, and cost. I want to be able to write a program that will tell me all the combinations of foods possible to buy under a given price range, and order the group from heaviest to lightest (so I am getting the most weight for my money).

For example. List all the combinations of 1 meat, 2 vegetables, and 3 fruits that you can get for under $16.60. List the combinations by total weight from heaviest to lightest.


Food,Type,Weight_(lb),Cost_USD
Meat1,M,2.40,5.99
Meat2,M,1.30,4.99
Meat3,M,3.20,3.99
Meat4,M,1.20,4.5
Meat5,M,2.10,5.5
Vegetable1,V,1.20,2.99
Vegetable2,V,1.40,3.49
Vegetable3,V,1.70,1.79
Vegetable4,V,1.20,4.69
Vegetable5,V,2.20,1.99
Fruit1,F,1.40,0.75
Fruit2,F,2.50,1.25
Fruit3,F,2.10,3.99
Fruit4,F,1.60,2.49
Fruit5,F,1.30,3.35
Last edited on
Topic archived. No new replies allowed.