String decoding to avoid unicode collisions for XLS output.

This commit is contained in:
Kenneth Reitz
2010-09-19 23:51:48 -04:00
parent 649c7e8bb7
commit 2c60ce9233
2 changed files with 15 additions and 7 deletions
+1 -1
View File
@@ -189,7 +189,7 @@ class Dataset(object):
ws = wb.add_sheet(self.title if self.title else 'Tabbed Dataset')
for i, row in enumerate(self._package(dicts=False)):
for j, col in enumerate(row):
ws.write(i, j, str(col))
ws.write(i, j, col.decode('utf8'))
wb.save(stream)
return stream.getvalue()
+14 -6
View File
@@ -156,23 +156,31 @@ class TablibTestCase(unittest.TestCase):
"""Verify exporting dataset object as CSV."""
# Build up the csv string with headers first, followed by each row
csv = ""
csv = ''
for col in self.headers:
csv += col + ","
csv += col + ','
csv = csv.strip(",") + "\r\n"
csv = csv.strip(',') + '\r\n'
for founder in self.founders:
for col in founder:
csv += str(col) + ","
csv = csv.strip(",") + "\r\n"
csv += str(col) + ','
csv = csv.strip(',') + '\r\n'
self.assertEqual(csv, self.founders.csv)
def test_unicode_append(self):
"""Passes in a single unicode charecter and exports."""
pass
new_row = ('å', 'é')
data.append(new_row)
data.json
data.yaml
data.csv
data.xls
if __name__ == '__main__':
unittest.main()