diff options
| author | Kenneth Reitz <me@kennethreitz.com> | 2010-11-17 20:48:50 -0500 |
|---|---|---|
| committer | Kenneth Reitz <me@kennethreitz.com> | 2010-11-17 20:48:50 -0500 |
| commit | 1a9aee928970ecaaba40529fd2def1e47059b828 (patch) | |
| tree | 14a978a170ab64f950259b032f0ddb20a32d1742 /tablib/core.py | |
| parent | 196edb82ccbfbca2fe6696f69973384cf570c7f9 (diff) | |
| download | tablib-1a9aee928970ecaaba40529fd2def1e47059b828.tar.gz | |
Column stacking only requires headers if headers exist.
Diffstat (limited to 'tablib/core.py')
| -rw-r--r-- | tablib/core.py | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/tablib/core.py b/tablib/core.py index 26923ea..7d3c94c 100644 --- a/tablib/core.py +++ b/tablib/core.py @@ -548,11 +548,11 @@ class Dataset(object): return _dset - def stack_rows(self, other): + def stack_rows(self, other): """Stack two :class:`Dataset` instances together by - joining them at the row level, and return a new - combined ``Dataset`` instance.""" + joining at the row level, and return new combined + ``Dataset`` instance.""" if not isinstance(other, Dataset): return @@ -571,23 +571,27 @@ class Dataset(object): return _dset - def stack_columns(self, other): + def stack_columns(self, other): """Stack two :class:`Dataset` instances together by joining at the column level, and return a new - combined ``Dataset`` instance. Requires headers - to be set.""" + combined ``Dataset`` instance. If either ``Dataset`` + has headers set, than the other must as well.""" if not isinstance(other, Dataset): return - if not self.headers or not other.headers: - raise HeadersNeeded + if self.headers or other.headers: + if not self.headers or not other.headers: + raise HeadersNeeded if self.height != other.height: raise InvalidDimensions - new_headers = self.headers + other.headers + try: + new_headers = self.headers + other.headers + except TypeError: + new_headers = None _dset = Dataset() |
