pola-rs/polars · error · ValueError
cannot use glob patterns and integer based projection as…
Error message
cannot use glob patterns and integer based projection as `columns` argument\n\nUse columns: List[str]
What it means
Guard in read_csv when the source is a glob pattern and `columns` was given as integer indices. Glob expansion means multiple files with possibly differing schemas, so positional column selection is ambiguous; the code path falls back to scan+collect which only supports name-based selection. Pass column names instead of indices.
Solutions
- When using glob patterns, pass columns as a list of column name strings (List[str]); integer projection cannot be combined with globs.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at py-polars/src/polars/io/csv/functions.py:734 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of pola-rs/polars@68506541d2 (2026-08-19).
Data as JSON: /api/errors/8d150f025101cb52.
Report an issue: GitHub.
Appendix: source
Thrown at py-polars/src/polars/io/csv/functions.py:730
new_columns
Provide an explicit list of string column names to use (for example, when
scanning a headerless CSV file). If the given list is shorter than the width of
the DataFrame the remaining columns will have their original name.
raise_if_empty
Control behavior when scanning empty files:
* `True`: Raise a `NoDataError`.
* `False`: Return 0 rows.
This defaults to `False` if `has_header=False` and a `schema` is specified,
and `True` otherwise.
truncate_ragged_lines
Truncate lines that are longer than the schema.
decimal_comma
Parse floats using a comma as the decimal separator instead of a period.
glob
Expand path given via globbing rules.
storage_options
Options that indicate how to connect to a cloud provider.
The cloud providers currently supported are AWS, GCP, and Azure.
See supported keys here:
* `aws <https://docs.rs/object_store/latest/object_store/aws/enum.AmazonS3ConfigKey.html>`_
* `gcp <https://docs.rs/object_store/latest/object_store/gcp/enum.GoogleConfigKey.html>`_
* `azure <https://docs.rs/object_store/latest/object_store/azure/enum.AzureConfigKey.html>`_
* Hugging Face (`hf://`): Accepts an API key under the `token` parameter: \
`{'token': '...'}`, or by setting the `HF_TOKEN` environment variable.
If `storage_options` is not provided, Polars will try to infer the information
from environment variables.
credential_provider
Provide a function that can be called to provide cloud storage
credentials. The function is expected to return a dictionary of
credential keys along with an optional credential expiry time.
View on GitHub (pinned to 68506541d2)