789f8e25 by 周伟奇

fix sheet name char

1 parent 91571bac
......@@ -79,6 +79,16 @@ TRANS_MAP = {
'B': "13",
}
TRANS = str.maketrans(TRANS_MAP)
SHEET_TITLE_TRANS_MAP = {
'/': "",
'\\': "",
'?': "",
'*': "",
'[': "",
']': "",
}
SHEET_TITLE_TRANS = str.maketrans(SHEET_TITLE_TRANS_MAP)
ERROR_CARD = '异常卡号'
ERROR_CHARS = {'.', '。', ':', ':', '•', '·', ',', ','}
RES_SHEET_NAME = '结果统计'
RES_SHEET_HEADER = ('页码', '图片序号', '检测图片序号', '结果')
......
......@@ -40,6 +40,18 @@ class BSWorkbook(Workbook):
return new_set
@staticmethod
def get_new_card(card):
if not isinstance(card, str):
return consts.ERROR_CARD
try:
new_card = card.translate(consts.SHEET_TITLE_TRANS).strip()[-6:]
if len(new_card) == 0:
new_card = consts.ERROR_CARD
except Exception as e:
new_card = consts.ERROR_CARD
return new_card
@staticmethod
def get_header_col(header_value, classify):
if header_value is None:
return
......@@ -540,10 +552,7 @@ class BSWorkbook(Workbook):
# }
# }
for card, summary in bs_summary.items():
try:
new_card = card[-6:].replace('*', '')
except Exception as e:
new_card = '异常卡号'
new_card = self.get_new_card(card)
# 1.原表表头收集、按照月份分割
# 1.1 总结首行信息
classify = summary.get('classify', 0)
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!