Add ODF (.ods) support via odfpy
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+11
-2
@@ -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]:
|
||||
|
||||
Reference in New Issue
Block a user