Add ODF (.ods) support via odfpy

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-13 11:48:03 +02:00
parent a0be34f66e
commit 2d9bce014f
4 changed files with 33 additions and 3 deletions
+11 -2
View File
@@ -5,8 +5,17 @@ import pandas as pd
from .config import SheetConfig
_ENGINES = {
".xls": "xlrd",
".xlsx": "openpyxl",
".xlsm": "openpyxl",
".xlsb": "openpyxl",
".ods": "odf",
}
def _engine_for(path: Path) -> str:
return "xlrd" if path.suffix.lower() == ".xls" else "openpyxl"
return _ENGINES[path.suffix.lower()]
class ExcelReader:
@@ -14,7 +23,7 @@ class ExcelReader:
self.path = Path(path)
if not self.path.exists():
raise FileNotFoundError(f"Excel file not found: {self.path}")
if self.path.suffix.lower() not in {".xls", ".xlsx", ".xlsm", ".xlsb"}:
if self.path.suffix.lower() not in _ENGINES:
raise ValueError(f"Unsupported file type: {self.path.suffix}")
def sheet_names(self) -> list[str]: