pola-rs/polars · error · RuntimeError

table named not found in sheet / else / no named tables…

Error message

table named {table_name!r} not found in sheet {sheet_name!r} / else / no named tables found in sheet {sheet_name!r} (looking for {table_name!r})

What it means

Raised by the openpyxl reader when `table_name` is given without `sheet_name` and the named table cannot be located in any worksheet. The message distinguishes between no tables existing at all and the specific table being absent.

Solutions

  1. Confirm the named table exists in the target sheet; correct table_name or sheet_name.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at py-polars/src/polars/io/spreadsheet/functions.py:1219 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of pola-rs/polars@5d8ebabf11 (2026-08-19). Data as JSON: /api/errors/736029358d73b0d0. Report an issue: GitHub.

Appendix: source

Thrown at py-polars/src/polars/io/spreadsheet/functions.py:1222

    has_header = read_options.pop("has_header", True)
    schema_overrides = schema_overrides or {}
    no_inference = infer_schema_length == 0
    header: list[str | None] = []

    if table_name and not sheet_name:
        ws, sheet_name, n_tables = None, None, 0
        for sheet in parser.worksheets:
            n_tables += 1
            if table_name in sheet.tables:
                ws, sheet_name = sheet, sheet.title
                break
        if ws is None:
            msg = (
                f"table named {table_name!r} not found in sheet {sheet_name!r}"
                if n_tables
                else f"no named tables found in sheet {sheet_name!r} (looking for {table_name!r})"
            )
            raise RuntimeError(msg)
    else:
        ws = parser[sheet_name]

    # prefer detection of actual table objects; otherwise read
    # data in the used worksheet range, dropping null columns
    if tables := getattr(ws, "tables", None):
        table = tables[table_name] if table_name else next(iter(tables.values()))
        rows = list(ws[table.ref])
        if not rows:
            return _empty_frame(raise_if_empty)
        if has_header:
            header.extend(cell.value for cell in rows.pop(0))
        else:
            header.extend(f"column_{n}" for n in range(len(rows[0])))
        if table.totalsRowCount:
            rows = rows[: -table.totalsRowCount]
        rows_iter = rows
    elif table_name:

View on GitHub (pinned to 5d8ebabf11)