mirror of
https://github.com/1Panel-dev/MaxKB.git
synced 2025-12-26 01:33:05 +00:00
fix: 修复excel导入失败问题 (#554)
This commit is contained in:
parent
399b2727e8
commit
efe5a2b021
|
|
@ -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('分段内容'):
|
||||
|
|
|
|||
|
|
@ -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],
|
||||
|
|
|
|||
Loading…
Reference in New Issue