From 864f29cc4b833fc3ac8cdeaa695d5894901d35b5 Mon Sep 17 00:00:00 2001 From: Mark Walling Date: Thu, 30 Jun 2011 22:38:57 -0400 Subject: [PATCH] Updated some docstrings in core.py * Binary warning for CSV output, because if you don't, Excel gets upset when Python translates \r\n to \r\n\r\n * Cleaned up what looked like a couple of copy paste errors --- tablib/core.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/tablib/core.py b/tablib/core.py index 53f3767..1025b61 100644 --- a/tablib/core.py +++ b/tablib/core.py @@ -433,7 +433,7 @@ class Dataset(object): .. admonition:: Binary Warning - :class:`Dataset.xlsx` contains binary data, so make sure to write in binary mode:: + :class:`Dataset.ods` contains binary data, so make sure to write in binary mode:: with open('output.ods', 'wb') as f: f.write(data.ods)' @@ -452,6 +452,17 @@ class Dataset(object): data.csv = 'age, first_name, last_name\\n90, John, Adams' Import assumes (for now) that headers exist. + + .. admonition:: Binary Warning + + :class:`Dataset.csv` uses \\r\\n line endings by default, so make + sure to write in binary mode:: + + with open('output.csv', 'wb') 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 @@ -477,7 +488,7 @@ class Dataset(object): set, a YAML list of objects will be returned. If no headers have been set, a YAML list of lists (rows) will be returned instead. - A dataset object can also be imported by setting the :class:`Dataset.json` attribute: :: + A dataset object can also be imported by setting the :class:`Dataset.yaml` attribute: :: data = tablib.Dataset() data.yaml = '- {age: 90, first_name: John, last_name: Adams}'