~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.
Python academiaanthropicarxivbravedeep-researchencryptionhome-automationhomeserverlocallocal-deep-researchlocal-llmmistralollamaopenaipubmedresearchresearch-toolretrieval-augmented-generationsearxngself-hosted
fix(loaders): keep an .xls cell that literally says N/A or NULL (#6522)
Lukasea37bfefd813
diff --git a/src/local_deep_research/document_loaders/xls_loader.py b/src/local_deep_research/document_loaders/xls_loader.pyindex b515d643cc..a90080bba4 100644--- a/src/local_deep_research/document_loaders/xls_loader.py+++ b/src/local_deep_research/document_loaders/xls_loader.py@@ -38,6 +38,11 @@ class XLSLoader(BaseLoader):sheet_name=None,header=None,engine="xlrd",+ # pandas reads the literal strings "N/A", "NA", "n/a", "NULL",+ # "None", "NaN" and "nan" as missing values, so a cell saying any+ # of them would be dropped by the pd.notna filter below. "N/A" is+ # how a person writes "not applicable"; the cell means something.+ keep_default_na=False,)except Exception as exc:msg = str(exc).lower()@@ -51,7 +56,13 @@ class XLSLoader(BaseLoader):for sheet_name, frame in sheets.items():lines = []for row in frame.itertuples(index=False, name=None):- cells = [str(value) for value in row if pd.notna(value)]+ # A blank cell now arrives as "" rather than NaN, and is+ # skipped the same way.+ cells = [+ text+ for value in row+ if pd.notna(value) and (text := str(value)) != ""+ ]if cells:lines.append(" ".join(cells))text = "\n".join(lines).strip()diff --git a/tests/document_loaders/test_office_format_extraction.py b/tests/document_loaders/test_office_format_extraction.pyindex f97789f1d8..aa7663ef36 100644--- a/tests/document_loaders/test_office_format_extraction.py+++ b/tests/document_loaders/test_office_format_extraction.py@@ -117,6 +117,74 @@ class TestOfficeExtractionRoundTrip:assert text is not Noneassert "Animal" in text and "Otter" in text and "Badger" in text+ def test_xls_keeps_a_cell_that_literally_says_na(self):+ """pandas reads "N/A" and friends as missing values.++ Such a cell was dropped by the ``pd.notna`` filter, so a status column+ full of "not applicable" left no trace in the extracted text.+ """+ xlwt = pytest.importorskip("xlwt")+ pytest.importorskip("xlrd")++ from local_deep_research.document_loaders import (+ extract_text_from_bytes,+ )++ literal_na = ["N/A", "NA", "n/a", "NULL", "None", "NaN", "nan"]++ wb = xlwt.Workbook()+ ws = wb.add_sheet("Data")+ ws.write(0, 0, "Code")+ ws.write(0, 1, "Status")+ for row, value in enumerate(literal_na, start=1):+ ws.write(row, 0, f"A{row}")+ ws.write(row, 1, value)+ with tempfile.NamedTemporaryFile(suffix=".xls", delete=False) as tmp:+ xls_path = tmp.name+ try:+ wb.save(xls_path)+ content = Path(xls_path).read_bytes()+ finally:+ Path(xls_path).unlink(missing_ok=True)++ text = extract_text_from_bytes(content, ".xls", "sample.xls")++ assert text is not None+ for row, value in enumerate(literal_na, start=1):+ assert f"A{row} {value}" in text++ def test_xls_skips_a_genuinely_empty_cell(self):+ """The control: keeping the literal strings must not make a blank visible."""+ xlwt = pytest.importorskip("xlwt")+ pytest.importorskip("xlrd")++ from local_deep_research.document_loaders import (+ extract_text_from_bytes,+ )++ wb = xlwt.Workbook()+ ws = wb.add_sheet("Data")+ ws.write(0, 0, "Code")+ ws.write(0, 1, "Status")+ ws.write(0, 2, "Units")+ ws.write(1, 0, "A1")+ # column 1 left unwritten: a real blank+ ws.write(1, 2, 12)+ with tempfile.NamedTemporaryFile(suffix=".xls", delete=False) as tmp:+ xls_path = tmp.name+ try:+ wb.save(xls_path)+ content = Path(xls_path).read_bytes()+ finally:+ Path(xls_path).unlink(missing_ok=True)++ text = extract_text_from_bytes(content, ".xls", "sample.xls")++ assert text is not None+ # A blank contributes nothing, and the number keeps its form rather+ # than being upcast to 12.0 by the NaN beside it.+ assert "A1 12" in text+def test_odt_extraction(self):pypandoc = pytest.importorskip("pypandoc")pytest.importorskip("docx")