{"record":{"id":"ce4b0ca0878b7480","repo":"pola-rs/polars","slug":"specified-column-names-do-not-start-with-column","errorCode":null,"errorMessage":"specified column names do not start with 'column_', but autogenerated header names were requested","messagePattern":"specified column names do not start with 'column_', but autogenerated header names were requested","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"py-polars/src/polars/io/csv/functions.py","lineNumber":371,"sourceCode":"    del columns\n    row_index = parse_row_index_args(row_index_name, row_index_offset)\n    del row_index_name\n    del row_index_offset\n\n    _check_arg_is_1byte(\"separator\", separator, can_be_empty=False)\n    _check_arg_is_1byte(\"quote_char\", quote_char, can_be_empty=True)\n    _check_arg_is_1byte(\"eol_char\", eol_char, can_be_empty=False)\n\n    storage_options = storage_options or {}\n\n    if column_names and not has_header:\n        for column in column_names:\n            if not column.startswith(\"column_\"):\n                msg = (\n                    \"specified column names do not start with 'column_',\"\n                    \" but autogenerated header names were requested\"\n                )\n                raise ValueError(msg)\n\n    if schema_overrides is not None and not isinstance(\n        schema_overrides, (dict, Sequence)\n    ):\n        msg = \"`schema_overrides` should be of type list or dict\"\n        raise TypeError(msg)\n\n    if raise_if_empty is None:\n        raise_if_empty = schema is None or has_header\n\n    if (\n        use_pyarrow\n        and schema_overrides is None\n        and n_rows is None\n        and not low_memory\n        and null_values is None\n        and with_column_names is None\n        and credential_provider == \"auto\"","sourceCodeStart":353,"sourceCodeEnd":389,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/py-polars/src/polars/io/csv/functions.py#L353-L389","documentation":"When `read_csv` is called with `has_header=False`, polars auto-generates column names like `column_1`, `column_2`, ... If the caller supplies explicit `schema`/column names that don't follow the `column_` prefix pattern in that mode, polars raises this ValueError because it cannot reconcile user-specified names with the requested autogeneration of header names.","triggerScenarios":"Calling `pl.read_csv(..., has_header=False, schema=[\"a\",\"b\"])` (or new_columns-style name list) where at least one provided name does not start with the literal string `column_`.","commonSituations":"Reading headerless files while trying to give custom names via `schema` instead of `new_columns`; mixing up which parameter assigns names for headerless CSVs; upgrading polars where the naming convention check became stricter.","solutions":["Pass your custom names via the parameter designed for it (`new_columns`) instead of `schema` with `has_header=False`.","Alternatively set `has_header=True` if the file actually has a header row and provide names normally.","Or rename your provided names to the `column_N` pattern to match autogenerated names.","Check polars docs for the installed version, as the interplay of `schema`, `has_header`, and `new_columns` has changed across releases."],"exampleFix":"// before\npl.read_csv(\"f.csv\", has_header=False, schema=[\"a\", \"b\"])\n# after\npl.read_csv(\"f.csv\", has_header=False, new_columns=[\"a\", \"b\"])","handlingStrategy":"validation","validationCode":"if has_header is False and schema is not None:\n    if not all(c.startswith(\"column_\") for c in schema):\n        # switch to new_columns instead\n        new_columns = schema\n        schema = None","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use `new_columns` for renaming headerless CSVs, not `schema`.","Decide explicitly whether the file has a header before choosing schema parameters.","Check the polars version's docs when mixing `schema`/`has_header`/`new_columns`."],"tags":["python","csv","schema","validation"],"backgroundTag":"schema-validation-failed","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"}