Skip to content

Commit

Permalink
TODO: calculate the total cost of each item
Browse files Browse the repository at this point in the history
  • Loading branch information
kubarium committed Feb 15, 2017
1 parent 14125e6 commit 7974156
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions dataminer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from pandas import read_csv
from collections import OrderedDict
import json
from functools import reduce

print(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")

Expand Down Expand Up @@ -30,14 +31,24 @@
product.pop(ingredient, None)


def cost(product):
pass


def get(name):
for product in products:
if product["name"] == name:
return product

numbers = [1, 2, 3]


def cost(product):
#global numbers
# return list(map(lambda item : item + 1, numbers))
return reduce((lambda lastCost, newCost: lastCost + newCost), map(lambda item: get(item)["cost"], get(product)["composition"]), get(product)["cost"])
# print(get(product)["composition"])

item = "Garden Houses"
print(get(item)["composition"])
print(cost(item))


with open("src/data.json", "w") as file:
json.dump(products, file, indent="\t")

0 comments on commit 7974156

Please sign in to comment.