def post(self): rnk_dict=dict() sum_money = 0 sum_number = 0 source_list=['全部','PC+天猫','实体店','手机端'] try: start = self.get_argument('start', '') end = self.get_argument('end', '') brand = self.get_argument('brand', []) source = self.get_argument('source', '全部') info_list = list() if self.request.files: csv_file = self.request.files['file'][0] fin = open("static/xls/"+csv_file['filename'],"w") fin.write(csv_file["body"]) fin.close() data = xlrd.open_workbook("static/xls/"+csv_file['filename']) table = data.sheets()[0] nrows = table.nrows #行数 ncols = table.ncols #列数 colnames = table.row_values(0) #某一行数据 for rownum in range(1,nrows): row = table.row_values(rownum) if row: app = {} for i in range(len(colnames)): app[colnames[i]] = row[i] info_list.append(app) if not start or not end: start = "开始日期" end = "结束日期" raise StandardError() r = ProSkuModule(self.application.dc) b = brand s = source rnk_dict,source,brand = r.get_list(b, s, start, end, info_list) except: logging.info( traceback.format_exc() ) return self.render('prosku.html', rnk_dict=rnk_dict, start = start, end = end, source_list = source_list, source = source, brand = brand) pass
def get(self): rnk_dict=dict() sum_money = 0 sum_number = 0 source_list=['全部','PC+天猫','实体店','手机端'] try: start = self.get_argument('start', '') end = self.get_argument('end', '') brand = self.get_argument('brand', []) source = self.get_argument('source', '全部') if not start or not end: start = "开始日期" end = "结束日期" raise StandardError() r = ProSkuModule(self.application.dc) b = brand s = source rnk_dict,source,brand = r.get_list(b, s, start, end) except: logging.info( traceback.format_exc() ) return self.render('prosku.html', rnk_dict=rnk_dict, start = start, end = end, source_list = source_list, source = source, brand = brand) pass