Skip to content

Commit c97a307

Browse files
authored
fix: Make read_csv_batched respect skip_rows and skip_lines (#23484)
1 parent 41b7597 commit c97a307

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

crates/polars-python/src/batched_csv.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ impl PyBatchedCsv {
100100
.with_has_header(has_header)
101101
.with_n_rows(n_rows)
102102
.with_skip_rows(skip_rows)
103-
.with_skip_rows(skip_lines)
103+
.with_skip_lines(skip_lines)
104104
.with_ignore_errors(ignore_errors)
105105
.with_projection(projection.map(Arc::new))
106106
.with_rechunk(rechunk)

py-polars/polars/io/csv/functions.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -742,6 +742,7 @@ def read_csv_batched(
742742
comment_prefix: str | None = None,
743743
quote_char: str | None = '"',
744744
skip_rows: int = 0,
745+
skip_lines: int = 0,
745746
schema_overrides: (
746747
Mapping[str, PolarsDataType] | Sequence[PolarsDataType] | None
747748
) = None,
@@ -806,7 +807,13 @@ def read_csv_batched(
806807
Single byte character used for csv quoting, default = `"`.
807808
Set to None to turn off special handling and escaping of quotes.
808809
skip_rows
809-
Start reading after `skip_rows` lines.
810+
Start reading after ``skip_rows`` rows. The header will be parsed at this
811+
offset. Note that we respect CSV escaping/comments when skipping rows.
812+
If you want to skip by newline char only, use `skip_lines`.
813+
skip_lines
814+
Start reading after `skip_lines` lines. The header will be parsed at this
815+
offset. Note that CSV escaping will not be respected when skipping lines.
816+
If you want to skip valid CSV rows, use ``skip_rows``.
810817
schema_overrides
811818
Overwrite dtypes during inference.
812819
null_values
@@ -1019,6 +1026,7 @@ def read_csv_batched(
10191026
comment_prefix=comment_prefix,
10201027
quote_char=quote_char,
10211028
skip_rows=skip_rows,
1029+
skip_lines=skip_lines,
10221030
schema_overrides=schema_overrides,
10231031
null_values=null_values,
10241032
missing_utf8_is_empty_string=missing_utf8_is_empty_string,

0 commit comments

Comments
 (0)