-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CSV parsing: ComputeError #15854
Comments
Note that data = pl.scan_csv("test.csv", schema=schema) ...where the file and the I have a very similar issue open already. Basically this comes down to very poor error messages when the |
That is odd. Just a visualization of how import tempfile
import polars as pl
f = tempfile.NamedTemporaryFile()
f.write(b"""
A,B
1,2
""".strip())
f.seek(0)
pl.read_csv(f.name, schema={"B": pl.String, "A": pl.Int32})
# shape: (1, 2)
# ┌─────┬─────┐
# │ B ┆ A │
# │ --- ┆ --- │
# │ str ┆ i32 │
# ╞═════╪═════╡
# │ 1 ┆ 2 │
# └─────┴─────┘
pl.scan_csv(f.name, schema={"B": pl.String, "A": pl.Int32}).collect()
# shape: (1, 2)
# ┌─────┬─────┐
# │ A ┆ B │
# │ --- ┆ --- │
# │ i32 ┆ str │
# ╞═════╪═════╡
# │ 1 ┆ 2 │
# └─────┴─────┘ [Update]: - It seems #11723 contains a mention of it. Found in the redesign issue: |
Ran into this issue as well. It is particularly surprising because from io import StringIO
import polars as pl
csv = """A,B
1,"foo"
3,"bar"
"""
buf = StringIO(csv)
# Works fine
schema_good = {"A": pl.Int64, "B": pl.String}
pl.read_csv(buf, schema=schema_good)
# Raises ComputeError
buf.seek(0)
schema_bad = {"B": pl.String, "A": pl.Int64}
pl.read_csv(buf, schema=schema_bad) |
Checks
Reproducible example
Use the following CSV file:
And the following Python script:
Output:
Installed versions
The text was updated successfully, but these errors were encountered: