Skip to content

Commit eaca11d

Browse files
authored
Merge pull request #124 from fosslight/out_of_range
Fix the index out of range bug
2 parents a5f19a2 + 7438661 commit eaca11d

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/fosslight_util/write_excel.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,11 @@ def write_result_to_csv(output_file, sheet_list_origin, separate_sheet=False, ex
138138
continue
139139
else:
140140
output_file = separate_output_file + "_" + sheet_name + file_extension
141-
142-
sheet_content_without_header = sorted(sheet_content_without_header,
143-
key=lambda x: (x[IDX_EXCLUDE], x[IDX_FILE] == "", x[IDX_FILE]))
141+
try:
142+
sheet_content_without_header = sorted(sheet_content_without_header,
143+
key=lambda x: (x[IDX_EXCLUDE], x[IDX_FILE] == "", x[IDX_FILE]))
144+
except Exception:
145+
pass
144146
with open(output_file, 'w', newline='') as file:
145147
writer = csv.writer(file, delimiter='\t')
146148
writer.writerow(header_row)
@@ -170,8 +172,11 @@ def write_result_to_excel(out_file_name, sheet_list, extended_header={}):
170172
workbook = xlsxwriter.Workbook(out_file_name)
171173
for sheet_name, sheet_contents in sheet_list.items():
172174
selected_header, sheet_content_without_header = get_header_row(sheet_name, sheet_contents[:], extended_header)
173-
sheet_content_without_header = sorted(sheet_content_without_header,
174-
key=lambda x: (x[IDX_EXCLUDE], x[IDX_FILE] == "", x[IDX_FILE]))
175+
try:
176+
sheet_content_without_header = sorted(sheet_content_without_header,
177+
key=lambda x: (x[IDX_EXCLUDE], x[IDX_FILE] == "", x[IDX_FILE]))
178+
except Exception:
179+
pass
175180
worksheet = create_worksheet(workbook, sheet_name, selected_header)
176181
write_result_to_sheet(worksheet, sheet_content_without_header)
177182
workbook.close()

0 commit comments

Comments
 (0)