diff options
| author | Marc Abramowitz <marc@marc-abramowitz.com> | 2012-05-15 07:19:15 -0700 |
|---|---|---|
| committer | Marc Abramowitz <marc@marc-abramowitz.com> | 2012-05-15 07:19:15 -0700 |
| commit | a3781e3c896071e49d7cfbac7f24d3f0c5336be9 (patch) | |
| tree | 2373bcf36fd63d4dfc81b04acb845ce90c542a5e /tablib/core.py | |
| parent | 6a825a8a3965066a71ebf6719498fbd77d7fd912 (diff) | |
| download | tablib-a3781e3c896071e49d7cfbac7f24d3f0c5336be9.tar.gz | |
Changes for Python 3 compatibility, including vendorizing xlrd3
Diffstat (limited to 'tablib/core.py')
| -rw-r--r-- | tablib/core.py | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/tablib/core.py b/tablib/core.py index c52671e..b1f0aca 100644 --- a/tablib/core.py +++ b/tablib/core.py @@ -226,19 +226,21 @@ class Dataset(object): def __unicode__(self): result = [self.__headers] - result.extend(map(unicode, row) for row in self._data) + result.extend(list(map(unicode, row)) for row in self._data) # here, we calculate max width for each column - lens = (map(len, row) for row in result) - field_lens = map(max, zip(*lens)) + lens = (list(map(len, row)) for row in result) + field_lens = list(map(max, zip(*lens))) # delimiter between header and data - result.insert(1, [u'-' * length for length in field_lens]) + result.insert(1, ['-' * length for length in field_lens]) - format_string = u'|'.join(u'{%s:%s}' % item for item in enumerate(field_lens)) + format_string = '|'.join('{%s:%s}' % item for item in enumerate(field_lens)) - return u'\n'.join(format_string.format(*row) for row in result) + return '\n'.join(format_string.format(*row) for row in result) + def __str__(self): + return self.__unicode__() # --------- |
