{"record":{"id":"988f35ef11cdbc5f","repo":"pola-rs/polars","slug":"the-values-of-has-header-and-read-options-head","errorCode":null,"errorMessage":"the values of `has_header` and `read_options[\"header_row\"]` are not compatible","messagePattern":"the values of `has_header` and `read_options\\[\"header_row\"\\]` are not compatible","errorType":"validation","errorClass":"ParameterCollisionError","httpStatus":null,"severity":"error","filePath":"py-polars/src/polars/io/spreadsheet/functions.py","lineNumber":745,"sourceCode":"        return parsed_sheets\n    return next(iter(parsed_sheets.values()))\n\n\ndef _get_read_options(\n    read_options: dict[str, Any] | None,\n    *,\n    engine: ExcelSpreadsheetEngine,\n    columns: Sequence[int] | Sequence[str] | None,\n    infer_schema_length: int | None,\n    has_header: bool,\n) -> dict[str, Any]:\n    \"\"\"Normalise top-level parameters to engine-specific 'read_options' dict.\"\"\"\n    read_options = (read_options or {}).copy()\n\n    if engine == \"calamine\":\n        if (\"use_columns\" in read_options) and columns:\n            msg = 'cannot specify both `columns` and `read_options[\"use_columns\"]`'\n            raise ParameterCollisionError(msg)\n        elif read_options.get(\"header_row\") is not None and has_header is False:\n            msg = 'the values of `has_header` and `read_options[\"header_row\"]` are not compatible'\n            raise ParameterCollisionError(msg)\n        elif (\"schema_sample_rows\" in read_options) and (\n            infer_schema_length != N_INFER_DEFAULT\n        ):\n            msg = 'cannot specify both `infer_schema_length` and `read_options[\"schema_sample_rows\"]`'\n            raise ParameterCollisionError(msg)\n\n        read_options[\"schema_sample_rows\"] = infer_schema_length\n        if has_header is False and \"header_row\" not in read_options:\n            read_options[\"header_row\"] = None\n\n    elif engine == \"xlsx2csv\":\n        if (\"columns\" in read_options) and columns:\n            msg = 'cannot specify both `columns` and `read_options[\"columns\"]`'\n            raise ParameterCollisionError(msg)\n        elif (","sourceCodeStart":727,"sourceCodeEnd":763,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/py-polars/src/polars/io/spreadsheet/functions.py#L727-L763","documentation":"For the calamine engine, read_options['header_row'] and the top-level has_header flag must agree. ParameterCollisionError is raised when has_header=False but header_row is explicitly set — you cannot both deny a header and name its row.","triggerScenarios":"pl.read_excel(src, engine='calamine', has_header=False, read_options={'header_row': 3}).","commonSituations":"Mixing older has_header usage with newer read_options tuning copied from docs or other engines; refactors where one parameter was left behind.","solutions":["Remove has_header=False and let header_row define the header row, or drop header_row if has_header=False is intended.","Set header_row only when has_header is True (or unset).","Consolidate header configuration into one of the two parameters."],"exampleFix":"// before\npl.read_excel('wb.xlsx', has_header=False, read_options={'header_row': 3})\n// after\npl.read_excel('wb.xlsx', read_options={'header_row': 3})","handlingStrategy":"validation","validationCode":"if has_header is False and (read_options or {}).get('header_row') is not None:\n    raise ValueError('drop either has_header=False or read_options[\"header_row\"]')","typeGuard":null,"tryCatchPattern":"from polars.exceptions import ParameterCollisionError\ntry:\n    df = pl.read_excel(src, has_header=False, read_options={'header_row': r})\nexcept ParameterCollisionError:\n    df = pl.read_excel(src, read_options={'header_row': r})","preventionTips":["Configure header handling in exactly one place","Prefer read_options for engine-specific settings, top-level flags otherwise"],"tags":["polars","excel","parameter-collision","calamine"],"backgroundTag":"conflicting-config-options","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"}