Skip to content

Conversation

@kaapstorm
Copy link
Contributor

This is a rebase of PR #243 with an additional commit to ensure data is written to disk before creating the zip archive.

The change uses a named temp file instead of in-memory StringIO when creating the CSV export. (The output is still a zipped CSV file.)

This change is covered by test tests/test_writers.py::TestWriters::test_CsvTableWriter

jbinary and others added 2 commits November 7, 2025 11:23
this reduces the RAM usage significantly when exporting big tables by
using a temporary file for storage instead of dumping everything to RAM
for row in table.rows:
writer.writerow(row)

tempfile.flush() # Flush buffer before zip reads tempfile
Copy link
Contributor

Choose a reason for hiding this comment

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

is this to ensure the file is written?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, exactly, otherwise the zip file can contain an empty CSV file.

@kaapstorm kaapstorm merged commit 829f0f0 into master Nov 8, 2025
5 checks passed
@kaapstorm kaapstorm deleted the ease-ram-usage branch November 8, 2025 12:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants