-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
43 lines (33 loc) · 1.58 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import openpyxl
inv_file = openpyxl.load_workbook("inventory.xlsx")
product_list = inv_file["Sheet1"] # all row and column
products_per_supplier = {} # { 'Bipolar Bt' : 21 }
total_value_per_supplier = {} # { 'Bipolar Bt.': 24772595.86 }
products_under_10_inv = {} # {24: 2}
for product_row in range(2, product_list.max_row + 1):
supplier_name = product_list.cell(product_row, 4).value
inventory = product_list.cell(product_row, 2).value
price = product_list.cell(product_row, 3).value
product_num = product_list.cell(product_row, 1).value
inventory_price = product_list.cell(product_row, 5)
# calculation number of products per supplier
if supplier_name in products_per_supplier:
current_num_products = products_per_supplier.get(supplier_name)
products_per_supplier[supplier_name] = current_num_products + 1
else:
products_per_supplier[supplier_name] = 1
# calculation total value of inventory per supplier
if supplier_name in total_value_per_supplier:
current_total_value = total_value_per_supplier.get(supplier_name)
total_value_per_supplier[supplier_name] = current_total_value + inventory * price
else:
total_value_per_supplier[supplier_name] = inventory * price
# products less than 10
if inventory < 10:
products_under_10_inv[product_num] = inventory
# add value for total inventory price
inventory_price.value = inventory * price
print(products_per_supplier)
print(total_value_per_supplier)
print(products_under_10_inv)
inv_file.save("inventory_with_total_value.xlsx")