Created
March 27, 2024 12:11
-
-
Save lemonlatte/b370be057086db94a7f444129b4dfdc7 to your computer and use it in GitHub Desktop.
streaming-csv-generator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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