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

fix: Reading CSV with low_memory gave no data #16231

Merged
merged 4 commits into from
May 15, 2024

Conversation

nameexhaustion
Copy link
Collaborator

@nameexhaustion nameexhaustion commented May 15, 2024

Fixes #16010

I've left the code in but removed calls to them for now, as I think I will be looking to do proper refactoring later.

@github-actions github-actions bot added fix Bug fix python Related to Python Polars rust Related to Rust Polars labels May 15, 2024
Copy link

codecov bot commented May 15, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 80.83%. Comparing base (79a2cf1) to head (459bc06).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #16231      +/-   ##
==========================================
- Coverage   80.92%   80.83%   -0.10%     
==========================================
  Files        1393     1394       +1     
  Lines      179568   179948     +380     
  Branches     2909     2909              
==========================================
+ Hits       145321   145454     +133     
- Misses      33742    33989     +247     
  Partials      505      505              

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


batches += reader.next_batches(5) # type: ignore[operator]
Copy link
Collaborator Author

@nameexhaustion nameexhaustion May 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have adjusted this as the mmap batched reader isn't strictly respecting the batch size

pl.select(a=pl.repeat(1, 100)).write_csv(".env/data.csv")
f = pl.read_csv_batched(".env/data.csv", batch_size=5).next_batches
lst = []
while b := f(5):
    lst.extend(b)
print([x.height for x in lst])
# [11, 11, 11, 11, 11, 11, 11, 11, 11, 1]

@ritchie46 ritchie46 merged commit 253fd24 into pola-rs:main May 15, 2024
26 checks passed
@nameexhaustion nameexhaustion deleted the csv-batched branch May 15, 2024 09:34
MarcoGorelli pushed a commit to MarcoGorelli/polars that referenced this pull request May 15, 2024
Wouittone pushed a commit to Wouittone/polars that referenced this pull request Jun 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix Bug fix python Related to Python Polars rust Related to Rust Polars
Projects
None yet
Development

Successfully merging this pull request may close these issues.

When setting low_memory=True for scan_csv, if the input is large enough, the output is empty
2 participants