fix sheet name char
Showing
2 changed files
with
23 additions
and
4 deletions
| ... | @@ -79,6 +79,16 @@ TRANS_MAP = { | ... | @@ -79,6 +79,16 @@ TRANS_MAP = { |
| 79 | 'B': "13", | 79 | 'B': "13", |
| 80 | } | 80 | } |
| 81 | TRANS = str.maketrans(TRANS_MAP) | 81 | TRANS = str.maketrans(TRANS_MAP) |
| 82 | SHEET_TITLE_TRANS_MAP = { | ||
| 83 | '/': "", | ||
| 84 | '\\': "", | ||
| 85 | '?': "", | ||
| 86 | '*': "", | ||
| 87 | '[': "", | ||
| 88 | ']': "", | ||
| 89 | } | ||
| 90 | SHEET_TITLE_TRANS = str.maketrans(SHEET_TITLE_TRANS_MAP) | ||
| 91 | ERROR_CARD = '异常卡号' | ||
| 82 | ERROR_CHARS = {'.', '。', ':', ':', '•', '·', ',', ','} | 92 | ERROR_CHARS = {'.', '。', ':', ':', '•', '·', ',', ','} |
| 83 | RES_SHEET_NAME = '结果统计' | 93 | RES_SHEET_NAME = '结果统计' |
| 84 | RES_SHEET_HEADER = ('页码', '图片序号', '检测图片序号', '结果') | 94 | RES_SHEET_HEADER = ('页码', '图片序号', '检测图片序号', '结果') | ... | ... |
| ... | @@ -40,6 +40,18 @@ class BSWorkbook(Workbook): | ... | @@ -40,6 +40,18 @@ class BSWorkbook(Workbook): |
| 40 | return new_set | 40 | return new_set |
| 41 | 41 | ||
| 42 | @staticmethod | 42 | @staticmethod |
| 43 | def get_new_card(card): | ||
| 44 | if not isinstance(card, str): | ||
| 45 | return consts.ERROR_CARD | ||
| 46 | try: | ||
| 47 | new_card = card.translate(consts.SHEET_TITLE_TRANS).strip()[-6:] | ||
| 48 | if len(new_card) == 0: | ||
| 49 | new_card = consts.ERROR_CARD | ||
| 50 | except Exception as e: | ||
| 51 | new_card = consts.ERROR_CARD | ||
| 52 | return new_card | ||
| 53 | |||
| 54 | @staticmethod | ||
| 43 | def get_header_col(header_value, classify): | 55 | def get_header_col(header_value, classify): |
| 44 | if header_value is None: | 56 | if header_value is None: |
| 45 | return | 57 | return |
| ... | @@ -540,10 +552,7 @@ class BSWorkbook(Workbook): | ... | @@ -540,10 +552,7 @@ class BSWorkbook(Workbook): |
| 540 | # } | 552 | # } |
| 541 | # } | 553 | # } |
| 542 | for card, summary in bs_summary.items(): | 554 | for card, summary in bs_summary.items(): |
| 543 | try: | 555 | new_card = self.get_new_card(card) |
| 544 | new_card = card[-6:].replace('*', '') | ||
| 545 | except Exception as e: | ||
| 546 | new_card = '异常卡号' | ||
| 547 | # 1.原表表头收集、按照月份分割 | 556 | # 1.原表表头收集、按照月份分割 |
| 548 | # 1.1 总结首行信息 | 557 | # 1.1 总结首行信息 |
| 549 | classify = summary.get('classify', 0) | 558 | classify = summary.get('classify', 0) | ... | ... |
-
Please register or sign in to post a comment