diff --git a/apps/common/handle/base_parse_qa_handle.py b/apps/common/handle/base_parse_qa_handle.py index 79c49dbca..e65807c10 100644 --- a/apps/common/handle/base_parse_qa_handle.py +++ b/apps/common/handle/base_parse_qa_handle.py @@ -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('分段内容'): diff --git a/apps/common/handle/impl/qa/xlsx_parse_qa_handle.py b/apps/common/handle/impl/qa/xlsx_parse_qa_handle.py index d8dd97160..973737772 100644 --- a/apps/common/handle/impl/qa/xlsx_parse_qa_handle.py +++ b/apps/common/handle/impl/qa/xlsx_parse_qa_handle.py @@ -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],