mirror of
https://github.com/kennethreitz/tablib.git
synced 2026-06-05 23:10:17 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 551fc90461 |
+3
-19
@@ -1,27 +1,11 @@
|
||||
History
|
||||
=======
|
||||
|
||||
0.7.1 (2010-09-20)
|
||||
0.6.4 (2010-09-13)
|
||||
------------------
|
||||
|
||||
* Reverting methods back to properties.
|
||||
* Windows bug compenated in documentation.
|
||||
|
||||
|
||||
0.7.0 (2010-09-20)
|
||||
------------------
|
||||
|
||||
* Renamed DataBook Databook for consistiency.
|
||||
* Export properties changed to methods (XLS filename / StringIO bug).
|
||||
* Optional Dataset.xls(path='filename') support (for writing on windows).
|
||||
* Added utf-8 on the worksheet level.
|
||||
|
||||
|
||||
0.6.4 (2010-09-19)
|
||||
------------------
|
||||
|
||||
* Updated unicode export for XLS.
|
||||
* More exhaustive unit tests.
|
||||
* Updated unicode export for XLS
|
||||
* More exhaustive unit tests
|
||||
|
||||
|
||||
0.6.3 (2010-09-14)
|
||||
|
||||
+4
-3
@@ -106,8 +106,8 @@ EXCEL!
|
||||
++++++
|
||||
::
|
||||
|
||||
>>> open('people.xls', 'wb').write(data.xls)
|
||||
|
||||
>>> open('people.xls').write(data.xls)
|
||||
|
||||
It's that easy.
|
||||
|
||||
|
||||
@@ -131,6 +131,7 @@ If you'd like to contribute, simply fork `the repository`_, commit your changes
|
||||
|
||||
Roadmap
|
||||
-------
|
||||
- Add ability to add/remove full columns
|
||||
- Import datasets from CSV, JSON, YAML
|
||||
- Release CLI Interface
|
||||
- Auto-detect import format
|
||||
@@ -140,4 +141,4 @@ Roadmap
|
||||
- Plugin support
|
||||
|
||||
.. _`the repository`: http://github.com/kennethreitz/tablib
|
||||
.. _AUTHORS: http://github.com/kennethreitz/tablib/blob/master/AUTHORS
|
||||
.. _AUTHORS: http://github.com/kennethreitz/tablib/blob/master/AUTHORS
|
||||
@@ -18,7 +18,7 @@ if sys.argv[-1] == "publish":
|
||||
|
||||
setup(
|
||||
name='tablib',
|
||||
version='0.7.1',
|
||||
version='0.6.4',
|
||||
description='Format agnostic tabular data library (XLS, JSON, YAML, CSV)',
|
||||
long_description=open('README.rst').read() + '\n\n' +
|
||||
open('HISTORY.rst').read(),
|
||||
|
||||
+15
-13
@@ -21,8 +21,8 @@ from helpers import *
|
||||
# __all__ = ['Dataset', 'DataBook']
|
||||
|
||||
__name__ = 'tablib'
|
||||
__version__ = '0.7.1'
|
||||
__build__ = 0x000701
|
||||
__version__ = '0.6.4'
|
||||
__build__ = 0x000604
|
||||
__author__ = 'Kenneth Reitz'
|
||||
__license__ = 'MIT'
|
||||
__copyright__ = 'Copyright 2010 Kenneth Reitz'
|
||||
@@ -149,6 +149,7 @@ class Dataset(object):
|
||||
self.__headers = None
|
||||
|
||||
|
||||
|
||||
@property
|
||||
def dict(self):
|
||||
"""Returns python dict of Dataset."""
|
||||
@@ -160,11 +161,13 @@ class Dataset(object):
|
||||
"""Returns JSON representation of Dataset."""
|
||||
return json.dumps(self.dict)
|
||||
|
||||
|
||||
@property
|
||||
def yaml(self):
|
||||
"""Returns YAML representation of Dataset."""
|
||||
return yaml.dump(self.dict)
|
||||
|
||||
|
||||
@property
|
||||
def csv(self):
|
||||
"""Returns CSV representation of Dataset."""
|
||||
@@ -176,18 +179,18 @@ class Dataset(object):
|
||||
|
||||
return stream.getvalue()
|
||||
|
||||
|
||||
@property
|
||||
def xls(self):
|
||||
"""Returns XLS representation of Dataset."""
|
||||
stream = cStringIO.StringIO()
|
||||
|
||||
wb = xlwt.Workbook(encoding='utf8')
|
||||
wb = xlwt.Workbook()
|
||||
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, col)
|
||||
ws.write(i, j, col.decode('utf8'))
|
||||
|
||||
stream = cStringIO.StringIO()
|
||||
wb.save(stream)
|
||||
return stream.getvalue()
|
||||
|
||||
@@ -224,7 +227,7 @@ class Dataset(object):
|
||||
pass
|
||||
|
||||
|
||||
class Databook(object):
|
||||
class DataBook(object):
|
||||
"""A book of Dataset objects.
|
||||
Currently, this exists only for XLS workbook support.
|
||||
"""
|
||||
@@ -263,12 +266,13 @@ class Databook(object):
|
||||
"""The number of the Datasets within DataBook."""
|
||||
return len(self._datasets)
|
||||
|
||||
|
||||
@property
|
||||
def xls(self):
|
||||
"""Returns XLS representation of DataBook."""
|
||||
|
||||
|
||||
wb = xlwt.Workbook(encoding='utf8')
|
||||
stream = cStringIO.StringIO()
|
||||
wb = xlwt.Workbook()
|
||||
|
||||
for i, dset in enumerate(self._datasets):
|
||||
ws = wb.add_sheet(dset.title if dset.title else 'Sheet%s' % (i))
|
||||
@@ -276,14 +280,12 @@ class Databook(object):
|
||||
#for row in self._package(dicts=False):
|
||||
for i, row in enumerate(dset._package(dicts=False)):
|
||||
for j, col in enumerate(row):
|
||||
ws.write(i, j, col)
|
||||
ws.write(i, j, str(col))
|
||||
|
||||
|
||||
stream = cStringIO.StringIO()
|
||||
wb.save(stream)
|
||||
return stream.getvalue()
|
||||
|
||||
|
||||
|
||||
@property
|
||||
def json(self):
|
||||
"""Returns JSON representation of Databook."""
|
||||
|
||||
Reference in New Issue
Block a user