pola-rs/polars · error · NoDataError
no data found in the given workbook(s) and sheet(s)
Error message
no data found in the given workbook(s) and sheet(s)
What it means
After parsing all requested workbooks/sheets, read_excel/read_ods raise NoDataError if the result list is empty — no sheet could be read at all. This guards the return-value invariants (it must return a DataFrame or dict of DataFrames).
Solutions
- Verify the workbook(s) actually contain data on the requested sheet(s) by opening them in Excel/LibreOffice.
- Broaden the sheet selection (omit sheet_name/sheet_id, or pass sheet_id=None) to see which sheets parse.
- Increase read_options sample rows / adjust has_header if data exists but was skipped during parsing.
Defensive patterns
Strategy: try-catch
Try / catch
from polars.exceptions import NoDataError
try:
df = pl.read_excel(src, sheet_name=sheet)
except NoDataError:
all_sheets = pl.read_excel(src) # inspect what is available
raise RuntimeError(f'no data; sheets: {list(all_sheets)}') from None Prevention
- Open the workbook manually to confirm the sheets hold data
- Read all sheets (sheet_id=None) first to discover layout
- Check that filters like include_file_paths/sheet selection are not eliminating everything
When it happens
Trigger: All requested sheets are empty or unreadable so the parser skipped them; sheet_id/sheet_name filtered out every sheet; or the workbook files contained no usable data.
Common situations: Reading truly blank workbooks, sheets whose contents start far below the sampled rows, or requests like sheet_id=[5,6] on a 2-sheet workbook combined with other filtering.
Understand the failure class
Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.
Related errors
- empty Excel sheet If you want to read this as an empty…
- cannot create a second
- cannot specify both `columns` and `read_options["columns"]`
- cannot specify both `columns` and…
- cannot specify both `infer_schema_length` and…
AI-assisted analysis of pola-rs/polars@fe841f959e (2026-09-18).
Data as JSON: /api/errors/01503a5877f486ed.
Report an issue: GitHub.
Appendix: source
Thrown at py-polars/src/polars/io/spreadsheet/functions.py:96
src = str(src)
sources.append(src)
return sources, read_multiple_workbooks
def _standardize_duplicates(s: str) -> str:
"""Standardize columns with '_duplicated_n' names."""
return re.sub(r"_duplicated_(\d+)", repl=r"\1", string=s)
def _unpack_read_results(
frames: list[pl.DataFrame] | list[dict[str, pl.DataFrame]],
*,
read_multiple_workbooks: bool,
) -> Any:
if not frames:
msg = "no data found in the given workbook(s) and sheet(s)"
raise NoDataError(msg)
if not read_multiple_workbooks:
# one sheet from one workbook
return frames[0]
if isinstance(frames[0], pl.DataFrame):
# one sheet from multiple workbooks
return concat(frames, how="vertical_relaxed") # type: ignore[type-var]
else:
# multiple sheets from multiple workbooks
sheet_frames = defaultdict(list)
for res in frames:
for sheet, df in res.items(): # type: ignore[union-attr]
sheet_frames[sheet].append(df)
return {k: concat(v, how="vertical_relaxed") for k, v in sheet_frames.items()}
@overloadView on GitHub (pinned to fe841f959e)