{"record":{"id":"3cc5f3da78bc1689","repo":"pola-rs/polars","slug":"unsupported-table-format-table-repr-r","errorCode":null,"errorMessage":"unsupported table format: {table_repr!r}","messagePattern":"unsupported table format: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"py-polars/src/polars/convert/general.py","lineNumber":770,"sourceCode":"def _build_table_patterns(table_repr: TableRepr) -> _TablePatterns:\n    if table_repr is TableRepr.UTF8:\n        return _TablePatterns(\n            cell_edge=re.compile(r\"^[\\W+]*│\"),\n            cell_split=re.compile(r\"[│┆]\"),\n            header_div=re.compile(r\"^[╞═╪╡\\s]+$\"),\n            row_div=re.compile(r\"^[├╌┼┤─]+$\"),\n            rstrip_chars=\"│ \",\n        )\n    elif table_repr is TableRepr.ASCII:\n        return _TablePatterns(\n            cell_edge=re.compile(r\"^[\\W+]*[|]\"),\n            cell_split=re.compile(r\"[|]\"),\n            header_div=re.compile(r\"^[+=\\-\\s]+$\"),\n            row_div=re.compile(r\"^[|+\\-]+$\"),\n            rstrip_chars=\"| \",\n        )\n    msg = f\"unsupported table format: {table_repr!r}\"\n    raise ValueError(msg)\n\n\nclass TableRepr(Enum):  # noqa: D101\n    UTF8 = auto()\n    ASCII = auto()\n\n    @property\n    def patterns(self) -> _TablePatterns:  # noqa: D102\n        try:\n            return _TABLE_PATTERNS_CACHE[self]\n        except KeyError:\n            rx = _build_table_patterns(self)\n            _TABLE_PATTERNS_CACHE[self] = rx\n            return rx\n\n\ndef _extract_table(data: str) -> tuple[str, TableRepr] | None:\n    \"\"\"Extract a DataFrame table string and infer its format from the input.\"\"\"","sourceCodeStart":752,"sourceCodeEnd":788,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/py-polars/src/polars/convert/general.py#L752-L788","documentation":"`_build_table_patterns` maps a `TableRepr` variant (UTF8 or ASCII) to the regex patterns used to parse `polars` repr strings. This ValueError is raised when an unknown table representation format is requested.","triggerScenarios":"Calling `from_repr` (which reaches `patterns`) with a table representation that is not a recognized `TableRepr` member — effectively an internal/enum-level mismatch rather than a typical user-path error.","commonSituations":"Programmatically constructing TableRepr from an unvalidated string; custom tooling subclassing or wrapping from_repr with its own format values.","solutions":["Pass only valid formats: `TableRepr.UTF8` or `TableRepr.ASCII` (the plain boxed-style and ASCII `+---+`-style reprs Polars actually prints).","If parsing a custom table, normalize it first (e.g. to UTF8 bordered format).","Report a bug if this arises from standard `from_repr` usage with a genuine Polars repr."],"exampleFix":"// before\npl.from_repr(tbl, table_repr='utf-8')\n// after\npl.from_repr(tbl, table_repr=pl.convert.TableRepr.UTF8)","handlingStrategy":"validation","validationCode":"from polars.convert import TableRepr\nassert table_repr in (TableRepr.UTF8, TableRepr.ASCII)","typeGuard":null,"tryCatchPattern":"try:\n    df = pl.from_repr(s)\nexcept ValueError as e:\n    if 'unsupported table format' in str(e):\n        df = pl.from_repr(s)  # retry with default format after normalizing input","preventionTips":["Only pass TableRepr enum members, not raw strings","Normalize external table text to a supported Polars repr first"],"tags":["python","polars","value-error","parsing"],"backgroundTag":"invalid-enum-value","analyzedSha":"fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e","analyzedAt":"2026-09-18T22:14:11.667Z","contentChangedAt":"2026-09-18T22:14:11.667Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}