add split \n
Showing
2 changed files
with
29 additions
and
3 deletions
| ... | @@ -896,6 +896,7 @@ OTHER_CLASSIFY_SET = {OTHER_CLASSIFY} | ... | @@ -896,6 +896,7 @@ OTHER_CLASSIFY_SET = {OTHER_CLASSIFY} |
| 896 | LICENSE_CLASSIFY_SET_1 = {IC_CLASSIFY, VAT_CLASSIFY, MVC_CLASSIFY, MVI_CLASSIFY} | 896 | LICENSE_CLASSIFY_SET_1 = {IC_CLASSIFY, VAT_CLASSIFY, MVC_CLASSIFY, MVI_CLASSIFY} |
| 897 | LICENSE_CLASSIFY_SET_2 = {BL_CLASSIFY, UCI_CLASSIFY, EEP_CLASSIFY, DL_CLASSIFY, PP_CLASSIFY, BC_CLASSIFY} | 897 | LICENSE_CLASSIFY_SET_2 = {BL_CLASSIFY, UCI_CLASSIFY, EEP_CLASSIFY, DL_CLASSIFY, PP_CLASSIFY, BC_CLASSIFY} |
| 898 | 898 | ||
| 899 | NYYH_CLASSIFY = 17 | ||
| 899 | MS_CLASSIFY = 21 | 900 | MS_CLASSIFY = 21 |
| 900 | MS_ERROR_COL = (5, 6) | 901 | MS_ERROR_COL = (5, 6) |
| 901 | WECHART_CLASSIFY = 12 | 902 | WECHART_CLASSIFY = 12 | ... | ... |
| ... | @@ -312,7 +312,7 @@ class BSWorkbook(Workbook): | ... | @@ -312,7 +312,7 @@ class BSWorkbook(Workbook): |
| 312 | return res_str | 312 | return res_str |
| 313 | 313 | ||
| 314 | @staticmethod | 314 | @staticmethod |
| 315 | def wechart_func(row_value, pre_col, next_col): | 315 | def rm_cn_char(row_value, pre_col, next_col): |
| 316 | row_value = list(row_value) | 316 | row_value = list(row_value) |
| 317 | if isinstance(row_value[pre_col], str): | 317 | if isinstance(row_value[pre_col], str): |
| 318 | cn_chars = re.findall(consts.CN_RE, row_value[pre_col]) | 318 | cn_chars = re.findall(consts.CN_RE, row_value[pre_col]) |
| ... | @@ -324,6 +324,29 @@ class BSWorkbook(Workbook): | ... | @@ -324,6 +324,29 @@ class BSWorkbook(Workbook): |
| 324 | row_value[next_col] = '{0}\n{1}'.format(cn_str, row_value[next_col]) | 324 | row_value[next_col] = '{0}\n{1}'.format(cn_str, row_value[next_col]) |
| 325 | return row_value | 325 | return row_value |
| 326 | 326 | ||
| 327 | @staticmethod | ||
| 328 | def rm_second_row(row_value, amount_cell_idx, over_cell_idx): | ||
| 329 | row_value = list(row_value) | ||
| 330 | if isinstance(over_cell_idx, int) and isinstance(amount_cell_idx, int): | ||
| 331 | max_idx = max(over_cell_idx, amount_cell_idx) | ||
| 332 | elif isinstance(over_cell_idx, int): | ||
| 333 | max_idx = over_cell_idx | ||
| 334 | elif isinstance(amount_cell_idx, int): | ||
| 335 | max_idx = amount_cell_idx | ||
| 336 | else: | ||
| 337 | max_idx = 0 | ||
| 338 | if max_idx > 1: | ||
| 339 | append_list = [] | ||
| 340 | for i in range(2, max_idx+1): | ||
| 341 | if isinstance(row_value[i], str): | ||
| 342 | split_list = row_value[i].split('\n') | ||
| 343 | row_value[i] = split_list[0] | ||
| 344 | append_list.extend(split_list[1:]) | ||
| 345 | if isinstance(row_value[1], str): | ||
| 346 | append_list.insert(0, row_value[1]) | ||
| 347 | row_value[1] = '\n'.join(append_list) | ||
| 348 | return row_value | ||
| 349 | |||
| 327 | def build_month_sheet(self, ms, card, month_mapping, is_reverse, statistics_header_info, max_column, classify): | 350 | def build_month_sheet(self, ms, card, month_mapping, is_reverse, statistics_header_info, max_column, classify): |
| 328 | summary_cell_idx = statistics_header_info.get(consts.SUMMARY_KEY) | 351 | summary_cell_idx = statistics_header_info.get(consts.SUMMARY_KEY) |
| 329 | date_cell_idx = statistics_header_info.get(consts.DATE_KEY) | 352 | date_cell_idx = statistics_header_info.get(consts.DATE_KEY) |
| ... | @@ -357,9 +380,11 @@ class BSWorkbook(Workbook): | ... | @@ -357,9 +380,11 @@ class BSWorkbook(Workbook): |
| 357 | for row_value in ws.iter_rows(min_row=part[1], max_row=part[2], values_only=True): | 380 | for row_value in ws.iter_rows(min_row=part[1], max_row=part[2], values_only=True): |
| 358 | if any(row_value): | 381 | if any(row_value): |
| 359 | if classify == consts.WECHART_CLASSIFY: | 382 | if classify == consts.WECHART_CLASSIFY: |
| 360 | row_value = self.wechart_func(row_value, *consts.WECHART_ERROR_COL) | 383 | row_value = self.rm_cn_char(row_value, *consts.WECHART_ERROR_COL) |
| 361 | elif classify == consts.MS_CLASSIFY: | 384 | elif classify == consts.MS_CLASSIFY: |
| 362 | row_value = self.wechart_func(row_value, *consts.MS_ERROR_COL) | 385 | row_value = self.rm_cn_char(row_value, *consts.MS_ERROR_COL) |
| 386 | elif classify == consts.NYYH_CLASSIFY: | ||
| 387 | row_value = self.rm_second_row(row_value, amount_cell_idx, over_cell_idx) | ||
| 363 | new_ws.append(row_value) | 388 | new_ws.append(row_value) |
| 364 | # 3.2.提取信息、高亮 | 389 | # 3.2.提取信息、高亮 |
| 365 | amount_mapping = {} | 390 | amount_mapping = {} | ... | ... |
-
Please register or sign in to post a comment