Skip to content

feat(python!): Do not reset seek position when scanning from file-like objects - #28619

Draft
nameexhaustion wants to merge 7 commits into
nxs/2.0-csv-dispatchfrom
nxs/2.0-file-object-pos
Draft

feat(python!): Do not reset seek position when scanning from file-like objects#28619
nameexhaustion wants to merge 7 commits into
nxs/2.0-csv-dispatchfrom
nxs/2.0-file-object-pos

Conversation

@nameexhaustion

@nameexhaustion nameexhaustion commented Jul 31, 2026

Copy link
Copy Markdown
Collaborator

Currently they get reset to the start. After this PR we will instead read from the existing seek position.

I.e. -

import polars as pl
import io

f = io.StringIO("""\
A|B|C|D
1,2,3,4
""")

headers = f.readline().strip().split("|")

print(pl.scan_csv(f, has_header=False, new_columns=headers).collect())
# shape: (1, 4)
# ┌─────┬─────┬─────┬─────┐
# │ A   ┆ B   ┆ C   ┆ D   │
# │ --- ┆ --- ┆ --- ┆ --- │
# │ i64 ┆ i64 ┆ i64 ┆ i64 │
# ╞═════╪═════╪═════╪═════╡
# │ 1   ┆ 2   ┆ 3   ┆ 4   │
# └─────┴─────┴─────┴─────┘

@nameexhaustion
nameexhaustion changed the base branch from main to nxs/2.0-csv-dispatch July 31, 2026 06:56
@github-actions github-actions Bot added breaking python Change that breaks backwards compatibility for the Python package enhancement New feature or an improvement of an existing feature python Related to Python Polars changes-dsl Do not merge if this label is present and red. labels Jul 31, 2026
@github-actions github-actions Bot removed the changes-dsl Do not merge if this label is present and red. label Jul 31, 2026
@github-actions

Copy link
Copy Markdown
Contributor

The uncompressed lib size after this PR is 57.8590 MB.

@github-actions

Copy link
Copy Markdown
Contributor

The uncompressed lib size after this PR is 58.0356 MB.

@github-actions

Copy link
Copy Markdown
Contributor

The uncompressed lib size after this PR is 58.0356 MB.

@github-actions

Copy link
Copy Markdown
Contributor

The uncompressed lib size after this PR is 58.0356 MB.

@codecov

codecov Bot commented Jul 31, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.30769% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.36%. Comparing base (7d58365) to head (c0d5c2c).

Files with missing lines Patch % Lines
crates/polars-python/src/file.rs 92.30% 2 Missing ⚠️
Additional details and impacted files
@@                   Coverage Diff                    @@
##           nxs/2.0-csv-dispatch   #28619      +/-   ##
========================================================
- Coverage                 80.54%   80.36%   -0.19%     
========================================================
  Files                      1868     1868              
  Lines                    262210   262231      +21     
  Branches                   3141     3141              
========================================================
- Hits                     211206   210747     -459     
- Misses                    50191    50671     +480     
  Partials                    813      813              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking python Change that breaks backwards compatibility for the Python package enhancement New feature or an improvement of an existing feature python Related to Python Polars

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant