{"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/68506541d2de983056c9eb244e1ea05fab377dfc/py-polars/src/polars/io/csv/functions.py#L860-L896","documentation":"ValueError raised by pl.scan_csv because truncate_ragged_lines=False is logically incompatible with extra_columns='ignore'. Ignoring extra columns means tolerating ragged rows (truncation defaults on in that case), so explicitly forbidding truncation while ignoring extra columns contradicts itself and is rejected.","triggerScenarios":"pl.scan_csv('f.csv', extra_columns='ignore', truncate_ragged_lines=False) — files whose rows have more fields than the schema, where the user wants extras dropped but no truncation.","commonSituations":"Messy CSV exports with inconsistent row widths; migrating from read_csv error-handling combos; defensive parameter sets copied from other scan calls.","solutions":["Drop truncate_ragged_lines (let it default to True when extra_columns='ignore')","Or use extra_columns='raise'/'insert' with truncate_ragged_lines=False if you want strict truncation semantics","Pre-clean the file or use skip_rows/new_columns to normalize widths"],"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' and truncate_ragged_lines is False:\n    truncate_ragged_lines = None  # let it default to True","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Let truncate_ragged_lines default when using extra_columns='ignore'","Understand the semantics: ignore implies truncation","Profile messy CSVs separately before choosing flags"],"tags":["python","polars","csv","scan-csv","parameter-conflict"],"backgroundTag":"conflicting-options","analyzedSha":"68506541d2de983056c9eb244e1ea05fab377dfc","analyzedAt":"2026-08-28T18:02:35.179Z","contentChangedAt":"2026-08-28T18:02:35.179Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}