From efe5a2b02191fa187031d12e234dc9504cf11433 Mon Sep 17 00:00:00 2001 From: shaohuzhang1 <80892890+shaohuzhang1@users.noreply.github.com> Date: Mon, 27 May 2024 16:06:14 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8Dexcel=E5=AF=BC?= =?UTF-8?q?=E5=85=A5=E5=A4=B1=E8=B4=A5=E9=97=AE=E9=A2=98=20(#554)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/common/handle/base_parse_qa_handle.py | 2 ++ apps/common/handle/impl/qa/xlsx_parse_qa_handle.py | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) 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],