import xlrd
import xlwt
from xlutils.copy import copy
xlsx = xlrd.open_workbook('d:/7月下旬入库表.xlsx')
table = xlsx.sheet_by_index(0)
all_data = []
for n in range(1, table.nrows):
company = table.cell(n, 1).value
price = table.cell(n, 3).value
weight = table.cell(n, 4).value
data = {
'company': company, 'weight': weight,'price': price}
all_data.append(data)
#以下内容可以用pandas的groupby轻易实现,这里不引入新知识,使用一个笨办法
a_weight = []
a_total_price = []
b_weight = []
b_total_price = []
c_weight = []
c_total_price = []
d_weight = []
d_total_price = []
for i in all_data:
if i['company'] == '张三粮配'