Skip to content

Commit ef50cb4

Browse files
committed
Merge branch 'release/v3.0' into develop
2 parents 129b521 + 9795f39 commit ef50cb4

1 file changed

Lines changed: 12 additions & 10 deletions

File tree

excel_statistics/main.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -414,8 +414,9 @@ def partial_row_col_analysis(reference_df, out_df, row_file, col_file, row_targe
414414
out_df.at[row_target, col_target] += 1
415415

416416
else:
417-
raise ValueError(Fore.RED + "[ERROR] Possible Error found at index {} with data: [{}: {}], [{}: {}]".format(row_index, row_target_label, row_target, col_target_label, col_target))
418417
print_row_data(reference_df, default_case_name, row_index)
418+
raise ValueError(Fore.RED + "[ERROR] Possible Error found at index {} with data: [{}: {}], [{}: {}]".format(row_index, row_target_label, row_target, col_target_label, col_target))
419+
419420

420421
except ValueError:
421422
print_row_data(reference_df, default_case_name, row_index)
@@ -490,9 +491,9 @@ def extract_agency_info(agencies_regex_list, target_df):
490491

491492
for row_index in range(default_effective_offset, target_df[agency_column_name].index.size):
492493

493-
# print(target_df[row_index])
494494

495-
error_flag = True
495+
match_count = 0
496+
496497
for i in range(0, len(agencies_regex_list)):
497498
input_str = str(target_df[agency_column_name][row_index])
498499
found_flag = is_found_in(agencies_regex_list[i], input_str)
@@ -501,17 +502,18 @@ def extract_agency_info(agencies_regex_list, target_df):
501502
if debug_flag is True:
502503
print("Agency [{}] at index {} Found in {}".format(input_str, row_index, i))
503504

504-
error_flag = False
505+
# error_flag = False
505506
insert_df[agency_column_name][row_index] = (i + 1)
507+
match_count += 1
508+
509+
# break
506510

507-
break
508511

509-
if error_flag is True:
510-
raise ValueError(Fore.RED + "[ERROR]: Agency [{}] at index {} cannot be found in all the regex lists".format(str(target_df[agency_column_name][row_index]), row_index))
512+
if match_count != 1:
511513
insert_df[agency_column_name][row_index] = -1
514+
raise ValueError(Fore.RED + "[ERROR]: Agency [{}] at index {} cannot be found or have more than one matches".format(str(target_df[agency_column_name][row_index]), row_index))
515+
512516

513-
514-
515517
# print(insert_df)
516518

517519
target_df["Agency"] = insert_df
@@ -541,8 +543,8 @@ def extract_special_case_info(target_df):
541543
insert_df[special_case_column_name][row_index] = trial
542544

543545
if trial < 0:
544-
raise ValueError(Fore.RED + "[ERROR] Error while matching Special Case Regex at index {} !!".format(row_index))
545546
print_row_data(target_df, default_case_name, row_index)
547+
raise ValueError(Fore.RED + "[ERROR] Error while matching Special Case Regex at index {} !!".format(row_index))
546548

547549
if debug_flag is True:
548550
print("Special Case at index {} is marked as {}".format(row_index, insert_df[special_case_column_name][row_index]))

0 commit comments

Comments
 (0)