{"record":{"id":"afb138a1d8391350","repo":"pola-rs/polars","slug":"cannot-set-truncate-ragged-lines-false-with-extra","errorCode":null,"errorMessage":"cannot set truncate_ragged_lines=False with extra_columns='ignore'","messagePattern":"cannot set truncate_ragged_lines=False with extra_columns='ignore'","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"py-polars/src/polars/io/csv/functions.py","lineNumber":878,"sourceCode":"    if isinstance(source, (str, Path)):\n        source = normalize_filepath(source, check_not_directory=False)\n    elif is_path_or_str_sequence(source, allow_str=False):\n        source = [\n            normalize_filepath(source, check_not_directory=False) for source in source\n        ]\n\n    if not infer_schema:\n        infer_schema_length = 0\n\n    if extra_columns is not None:\n        msg = \"The `extra_columns` parameter of `scan_csv` is considered unstable.\"\n        issue_unstable_warning(msg)\n    else:\n        extra_columns = \"raise\"\n\n    if extra_columns == \"ignore\" and truncate_ragged_lines is False:\n        msg = \"cannot set truncate_ragged_lines=False with extra_columns='ignore'\"\n        raise ValueError(msg)\n\n    if truncate_ragged_lines is None:\n        truncate_ragged_lines = extra_columns == \"ignore\"\n\n    if missing_columns is not None:\n        msg = \"The `missing_columns` parameter of `scan_csv` is considered unstable.\"\n        issue_unstable_warning(msg)\n\n    credential_provider_builder = _init_credential_provider_builder(\n        credential_provider, source, storage_options, \"scan_csv\"\n    )\n    del credential_provider\n\n    dtype_list: list[tuple[str, PolarsDataType]] | None = None\n    dtype_slice: Sequence[PolarsDataType] | None = None\n    if schema_overrides is not None:\n        if isinstance(schema_overrides, dict):\n            dtype_list = []","sourceCodeStart":860,"sourceCodeEnd":896,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/py-polars/src/polars/io/csv/functions.py#L860-L896","documentation":"The unstable `extra_columns='ignore'` mode of `scan_csv` works by internally truncating ragged lines, so explicitly setting `truncate_ragged_lines=False` together with it is contradictory. Polars raises this ValueError rather than silently overriding one of the options.","triggerScenarios":"`pl.scan_csv(..., extra_columns=\"ignore\", truncate_ragged_lines=False)` — the caller explicitly disables ragged-line truncation while asking polars to ignore surplus columns, which requires truncation.","commonSituations":"Copy-pasting option sets from different examples; a config layer that always sets `truncate_ragged_lines=False` while another layer enables `extra_columns='ignore'`; misunderstanding that 'ignore extra columns' implies dropping cells on overlong rows.","solutions":["Omit `truncate_ragged_lines` (leave it None) when using `extra_columns='ignore'` — polars sets it to True automatically.","If you truly need `truncate_ragged_lines=False`, switch `extra_columns` to the default `\"raise\"` (or \"warn\").","Decide which behavior you want: either tolerate ragged rows (truncation) or error on them."],"exampleFix":"// before\npl.scan_csv(\"f.csv\", extra_columns=\"ignore\", truncate_ragged_lines=False)\n// after\npl.scan_csv(\"f.csv\", extra_columns=\"ignore\")","handlingStrategy":"validation","validationCode":"if extra_columns == \"ignore\":\n    truncate_ragged_lines = None  # let polars default it to True","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Don't hard-set truncate_ragged_lines in shared config when extra_columns is configurable.","Understand that extra_columns='ignore' implies truncating overlong rows.","Keep unstable-parameter usage isolated and commented."],"tags":["python","csv","lazy","conflicting-options"],"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"}