From e76b943d5f32b865f5ce9a547c6cd6b11a9b8aa7 Mon Sep 17 00:00:00 2001 From: Jyong <76649700+JohnJyong@users.noreply.github.com> Date: Tue, 10 Sep 2024 14:55:08 +0800 Subject: [PATCH] filter excel empty sheet (#8194) --- api/core/rag/extractor/excel_extractor.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/api/core/rag/extractor/excel_extractor.py b/api/core/rag/extractor/excel_extractor.py index f0c302a6197a64..526c66042ca244 100644 --- a/api/core/rag/extractor/excel_extractor.py +++ b/api/core/rag/extractor/excel_extractor.py @@ -38,7 +38,10 @@ def extract(self) -> list[Document]: for sheet_name in wb.sheetnames: sheet = wb[sheet_name] data = sheet.values - cols = next(data) + try: + cols = next(data) + except StopIteration: + continue df = pd.DataFrame(data, columns=cols) df.dropna(how='all', inplace=True)