Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into business
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoGorelli committed Apr 8, 2024
2 parents ff3bbd6 + c211fad commit ca7075d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions py-polars/polars/io/csv/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ def read_csv(
data,
pa.csv.ReadOptions(
skip_rows=skip_rows,
skip_rows_after_names=skip_rows_after_header,
autogenerate_column_names=not has_header,
encoding=encoding,
),
Expand Down
16 changes: 16 additions & 0 deletions py-polars/tests/unit/io/test_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -2037,3 +2037,19 @@ def test_csv_escape_cf_15349() -> None:
df.write_csv(f)
f.seek(0)
assert f.read() == b'test\nnormal\n"with\rcr"\n'


@pytest.mark.parametrize("use_pyarrow", [True, False])
def test_skip_rows_after_header_pyarrow(use_pyarrow: bool) -> None:
csv = textwrap.dedent(
"""\
foo,bar
1,2
3,4
5,6
"""
)
f = io.StringIO(csv)
df = pl.read_csv(f, skip_rows_after_header=1, use_pyarrow=use_pyarrow)
expected = pl.DataFrame({"foo": [3, 5], "bar": [4, 6]})
assert_frame_equal(df, expected)

0 comments on commit ca7075d

Please sign in to comment.