fix: 修复excel导入失败问题 (#554)

This commit is contained in:
shaohuzhang1 2024-05-27 16:06:14 +08:00 committed by GitHub
parent 399b2727e8
commit efe5a2b021
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 3 deletions

View File

@ -31,6 +31,8 @@ def get_title_row_index_dict(title_row_list):
title_row_index_dict['problem_list'] = 2
for index in range(len(title_row_list)):
title_row = title_row_list[index]
if title_row is None:
title_row = ''
if title_row.startswith('分段标题'):
title_row_index_dict['title'] = index
if title_row.startswith('分段内容'):

View File

@ -26,13 +26,13 @@ def handle_sheet(file_name, sheet):
paragraph_list = []
for row in rows:
content = get_row_value(row, title_row_index_dict, 'content')
if content is None:
if content is None or content.value is None:
continue
problem = get_row_value(row, title_row_index_dict, 'problem_list')
problem = str(problem.value) if problem is not None else ''
problem = str(problem.value) if problem is not None and problem.value is not None else ''
problem_list = [{'content': p[0:255]} for p in problem.split('\n') if len(p.strip()) > 0]
title = get_row_value(row, title_row_index_dict, 'title')
title = str(title.value) if title is not None else ''
title = str(title.value) if title is not None and title.value is not None else ''
content = content.value
paragraph_list.append({'title': title[0:255],
'content': content[0:4096],