Skip to content
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

read_csv ignores skip_rows_after_header when use_pyarrow=True #15497

Closed
2 tasks done
wikiped opened this issue Apr 5, 2024 · 1 comment · Fixed by #15533
Closed
2 tasks done

read_csv ignores skip_rows_after_header when use_pyarrow=True #15497

wikiped opened this issue Apr 5, 2024 · 1 comment · Fixed by #15533
Labels
bug Something isn't working P-low Priority: low python Related to Python Polars

Comments

@wikiped
Copy link

wikiped commented Apr 5, 2024

Checks

  • I have checked that this issue has not already been reported.
  • I have confirmed this bug exists on the latest version of Polars.

Reproducible example

import polars as pl
from pathlib import Path

file = Path('./test.csv')

with file.open('w') as f:
  f.write(
"""foo,bar
1,2
3,4
5,6
"""
  )

print('use_pyarrow=True')
print(pl.read_csv("test.csv", skip_rows_after_header=1, use_pyarrow=True))

print('use_pyarrow=False')
print(pl.read_csv("test.csv", skip_rows_after_header=1, use_pyarrow=False))

file.unlink()

Log output

No response

Issue description

Commands above output:

use_pyarrow=True
shape: (3, 2)
┌─────┬─────┐
│ foo ┆ bar │
│ ------ │
│ i64 ┆ i64 │
╞═════╪═════╡
│ 12   │
│ 34   │
│ 56   │
└─────┴─────┘

use_pyarrow=False
shape: (2, 2)
┌─────┬─────┐
│ foo ┆ bar │
│ ------ │
│ i64 ┆ i64 │
╞═════╪═════╡
│ 34   │
│ 56   │
└─────┴─────┘

Expected behavior

Regardless of what use_pyarrow is set to outputs should match

Installed versions

--------Version info---------
Polars:               0.20.18
Index type:           UInt32
Platform:             Windows-10-10.0.19045-SP0
Python:               3.12.2 (tags/v3.12.2:6abddd9, Feb  6 2024, 21:26:36) [MSC v.1937 64 bit (AMD64)]

----Optional dependencies----
adbc_driver_manager:  <not installed>
cloudpickle:          3.0.0
connectorx:           <not installed>
deltalake:            <not installed>
fastexcel:            0.10.3
fsspec:               2024.3.1
gevent:               <not installed>
hvplot:               <not installed>
matplotlib:           <not installed>
nest_asyncio:         1.6.0
numpy:                1.26.4
openpyxl:             3.1.2
pandas:               <not installed>
pyarrow:              15.0.2
pydantic:             2.6.4
pyiceberg:            <not installed>
pyxlsb:               <not installed>
sqlalchemy:           <not installed>
xlsx2csv:             <not installed>
xlsxwriter:           <not installed>
@wikiped wikiped added bug Something isn't working needs triage Awaiting prioritization by a maintainer python Related to Python Polars labels Apr 5, 2024
@cmdlineluser
Copy link
Contributor

It looks like pyarrow calls this skip_rows_after_names which would need to be added:

pa.csv.ReadOptions(
skip_rows=skip_rows,
autogenerate_column_names=not has_header,
encoding=encoding,
),

@reswqa reswqa added P-low Priority: low and removed needs triage Awaiting prioritization by a maintainer labels Apr 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working P-low Priority: low python Related to Python Polars
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants