fix bug
Showing
1 changed file
with
13 additions
and
7 deletions
... | @@ -79,18 +79,24 @@ class BSWorkbook(Workbook): | ... | @@ -79,18 +79,24 @@ class BSWorkbook(Workbook): |
79 | # } | 79 | # } |
80 | 80 | ||
81 | # 第一行关键词 | 81 | # 第一行关键词 |
82 | find_count = 0 | 82 | header_col_list = [] |
83 | for first_row in ws.iter_rows(max_row=1, min_row=1, values_only=True): | 83 | for first_row in ws.iter_rows(max_row=1, min_row=1, values_only=True): |
84 | sheet_header_info.setdefault(ws.title, {}).setdefault(consts.HEADER_KEY, first_row) | 84 | sheet_header_info.setdefault(ws.title, {}).setdefault(consts.HEADER_KEY, first_row) |
85 | for idx, header_value in enumerate(first_row): | 85 | for idx, header_value in enumerate(first_row): |
86 | header_col = self.get_header_col(header_value, classify) | 86 | header_col = self.get_header_col(header_value, classify) |
87 | if header_col is not None: | 87 | if header_col is not None: |
88 | find_count += 1 | 88 | header_col_list.append((idx, header_col)) |
89 | sheet_header_info.setdefault(ws.title, {}).setdefault(header_col, idx) | 89 | |
90 | find_col_set = sheet_header_info.setdefault(ws.title, {}).setdefault(consts.FIND_COL_KEY, set()) | 90 | find_count = len(header_col_list) |
91 | find_col_set.add(idx) | 91 | if find_count < 2: |
92 | col_count = header_info.setdefault(header_col, {}).get(idx) | 92 | find_count = 0 |
93 | header_info.setdefault(header_col, {})[idx] = 1 if col_count is None else col_count+1 | 93 | else: |
94 | for idx, header_col in header_col_list: | ||
95 | sheet_header_info.setdefault(ws.title, {}).setdefault(header_col, idx) | ||
96 | find_col_set = sheet_header_info.setdefault(ws.title, {}).setdefault(consts.FIND_COL_KEY, set()) | ||
97 | find_col_set.add(idx) | ||
98 | col_count = header_info.setdefault(header_col, {}).get(idx) | ||
99 | header_info.setdefault(header_col, {})[idx] = 1 if col_count is None else col_count+1 | ||
94 | 100 | ||
95 | sheet_header_info.setdefault(ws.title, {}).setdefault(consts.FIND_COUNT_KEY, find_count) | 101 | sheet_header_info.setdefault(ws.title, {}).setdefault(consts.FIND_COUNT_KEY, find_count) |
96 | min_row = 1 if find_count == 0 else 2 | 102 | min_row = 1 if find_count == 0 else 2 | ... | ... |
-
Please register or sign in to post a comment