Skip to content

Commit

Permalink
Added stream to CSV
Browse files Browse the repository at this point in the history
  • Loading branch information
ZuluPro committed Aug 8, 2018
1 parent 4c300e6 commit 36d3a40
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions tablib/formats/_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
DEFAULT_DELIMITER = ','


def export_set(dataset, **kwargs):
"""Returns CSV representation of Dataset."""
def export_stream_set(dataset, **kwargs):
"""Returns CSV representation of Dataset as file-like."""
stream = StringIO()

kwargs.setdefault('delimiter', DEFAULT_DELIMITER)
Expand All @@ -27,6 +27,13 @@ def export_set(dataset, **kwargs):
for row in dataset._package(dicts=False):
_csv.writerow(row)

stream.seek(0)
return stream


def export_set(dataset, **kwargs):
"""Returns CSV representation of Dataset."""
stream = export_stream_set(dataset, **kwargs)
return stream.getvalue()


Expand Down

0 comments on commit 36d3a40

Please sign in to comment.