Skip to content

Instantly share code, notes, and snippets.

@lemonlatte
Created March 27, 2024 12:11
Show Gist options
  • Save lemonlatte/b370be057086db94a7f444129b4dfdc7 to your computer and use it in GitHub Desktop.
Save lemonlatte/b370be057086db94a7f444129b4dfdc7 to your computer and use it in GitHub Desktop.
streaming-csv-generator
def streaming_csv_data(supplier_id: str):
buffer = io.StringIO()
with CSVWriter(buffer) as writer:
for row in _iter_data():
writer.writerow(row)
buffer.seek(0)
yield buffer.read()
buffer.seek(0)
buffer.truncate(0)
buffer.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment