summaryrefslogtreecommitdiff
path: root/tablib
diff options
context:
space:
mode:
authorKenneth Reitz <me@kennethreitz.com>2011-08-11 00:47:23 -0400
committerKenneth Reitz <me@kennethreitz.com>2011-08-11 00:47:23 -0400
commit906138b138e05670913ecf233b8430d59cb6d29b (patch)
tree3fce2deb2e300be2cc44e4d28ddc5ef792d78ff2 /tablib
parent43c68b396fd51a567f954297a686dcd828778037 (diff)
downloadtablib-906138b138e05670913ecf233b8430d59cb6d29b.tar.gz
a column w/ no length could work
Diffstat (limited to 'tablib')
-rw-r--r--tablib/core.py15
1 files changed, 9 insertions, 6 deletions
diff --git a/tablib/core.py b/tablib/core.py
index 166d18e..485d610 100644
--- a/tablib/core.py
+++ b/tablib/core.py
@@ -130,7 +130,7 @@ class Dataset(object):
data.append(('John', 'Adams'))
data.append(('George', 'Washington'))
- data.append_col((90, 67), header='age')
+ data.append_col((90, 67), header='age')
You can also set rows and headers upon instantiation. This is useful if dealing
@@ -470,7 +470,7 @@ 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
@@ -478,7 +478,7 @@ class Dataset(object):
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.
"""
@@ -550,7 +550,7 @@ class Dataset(object):
Rows inserted must be the correct size (height or width).
The default behaviour is to insert the given row to the :class:`Dataset`
- object at the given index.
+ object at the given index.
"""
self._validate(row)
@@ -635,9 +635,12 @@ class Dataset(object):
If inserting a row, you can add :ref:`tags <tags>` to the row you are inserting.
This gives you the ability to :class:`filter <Dataset.filter>` your
:class:`Dataset` later.
-
+
"""
+ if col is None:
+ col = []
+
# Callable Columns...
if hasattr(col, '__call__'):
col = list(map(col, self._data))
@@ -651,7 +654,7 @@ class Dataset(object):
raise HeadersNeeded()
# corner case - if header is set without data
- elif header and self.height == 0:
+ elif header and self.height == 0 and len(col):
raise InvalidDimensions
self.headers.insert(index, header)