diff options
| author | Tom Christie <tom@tomchristie.com> | 2016-02-25 13:28:29 +0000 |
|---|---|---|
| committer | Tom Christie <tom@tomchristie.com> | 2016-02-25 13:28:29 +0000 |
| commit | d720beadac14ae051a424f1ad1add17cf7b6d240 (patch) | |
| tree | 6378d8b3b72a5945daea38fdb70f7ba3c0754e3d /tablib/core.py | |
| parent | ee9666a146514573a2a159baaabb0481a7e2c5c0 (diff) | |
| download | tablib-d720beadac14ae051a424f1ad1add17cf7b6d240.tar.gz | |
Fixed __unicode__/__str__ for dataset with no headers
Diffstat (limited to 'tablib/core.py')
| -rw-r--r-- | tablib/core.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/tablib/core.py b/tablib/core.py index 3db24f3..aa787f4 100644 --- a/tablib/core.py +++ b/tablib/core.py @@ -223,7 +223,8 @@ class Dataset(object): result = [] # Add unicode representation of headers. - result.append([unicode(h) for h in self.__headers]) + if self.__headers: + result.append([unicode(h) for h in self.__headers]) # Add unicode representation of rows. result.extend(list(map(unicode, row)) for row in self._data) @@ -232,7 +233,8 @@ class Dataset(object): field_lens = list(map(max, zip(*lens))) # delimiter between header and data - result.insert(1, ['-' * length for length in field_lens]) + if self.__headers: + result.insert(1, ['-' * length for length in field_lens]) format_string = '|'.join('{%s:%s}' % item for item in enumerate(field_lens)) |
