From 61063e2b09a5cd26926311a34826fd33be0b1757 Mon Sep 17 00:00:00 2001 From: DougHudgeon Date: Mon, 25 Jun 2018 14:17:34 +1000 Subject: Updated xlsx format to use openpyxl's .active property --- tablib/formats/_xlsx.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tablib') diff --git a/tablib/formats/_xlsx.py b/tablib/formats/_xlsx.py index 20f55df..67aa5f4 100644 --- a/tablib/formats/_xlsx.py +++ b/tablib/formats/_xlsx.py @@ -71,7 +71,7 @@ def import_set(dset, in_stream, headers=True): dset.wipe() xls_book = openpyxl.reader.excel.load_workbook(BytesIO(in_stream)) - sheet = xls_book.get_active_sheet() + sheet = xls_book.active dset.title = sheet.title -- cgit v1.2.1 From f812c29275c7f47b08f8f1b962625545ec4e22ad Mon Sep 17 00:00:00 2001 From: DougHudgeon Date: Tue, 26 Jun 2018 10:33:21 +1000 Subject: Add instructions for handling csv line endings in Windows in Python 3 --- tablib/core.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'tablib') diff --git a/tablib/core.py b/tablib/core.py index 8c49f2e..e0d61f0 100644 --- a/tablib/core.py +++ b/tablib/core.py @@ -526,9 +526,9 @@ class Dataset(object): Import assumes (for now) that headers exist. - .. admonition:: Binary Warning + .. admonition:: Binary Warning for Python 2 - :class:`Dataset.csv` uses \\r\\n line endings by default, so make + :class:`Dataset.csv` uses \\r\\n line endings by default so, in Python 2, make sure to write in binary mode:: with open('output.csv', 'wb') as f: @@ -536,6 +536,18 @@ class Dataset(object): If you do not do this, and you export the file on Windows, your CSV file will open in Excel with a blank line between each row. + + .. admonition:: Line endings for Python 3 + + :class:`Dataset.csv` uses \\r\\n line endings by default so, in Python 3, make + sure to include newline='' otherwise you will get a blank line between each row + when you open the file in Excel:: + + with open('output.csv', 'w', newline='') as f: + f.write(data.csv) + + If you do not do this, and you export the file on Windows, your + CSV file will open in Excel with a blank line between each row. """ pass -- cgit v1.2.1