mirror of
https://github.com/kennethreitz/tablib.git
synced 2026-06-05 15:00:19 +00:00
Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2994a9fc0d | |||
| 9f025dc111 | |||
| 335e3b1134 | |||
| 6b4afc38d1 | |||
| bd3099897c | |||
| 4b6fbe9225 | |||
| f22357f1bc | |||
| 37ffbc71c0 | |||
| 6f7c64eb03 | |||
| 89be8f402f |
+8
-2
@@ -64,7 +64,7 @@ Populate fresh data files: ::
|
||||
|
||||
Intelligently add new rows: ::
|
||||
|
||||
data.adppend('Bob', 'Dylan', 3.2)
|
||||
data.append('Bob', 'Dylan', 3.2)
|
||||
|
||||
print data.headers
|
||||
# >>> ('first_name', 'last_name', 'gpa')
|
||||
@@ -95,4 +95,10 @@ Manipulate rows by index: ::
|
||||
.. Export to various formats: ::
|
||||
..
|
||||
.. # Save copy as CSV
|
||||
.. data.export('backup.csv')
|
||||
.. data.export('backup.csv')
|
||||
|
||||
Roadmap
|
||||
-------
|
||||
- Import datasets from CSV, JSON, YAML
|
||||
- Auto-detect import format
|
||||
- Plugin support
|
||||
@@ -8,29 +8,36 @@ from distutils.core import setup
|
||||
|
||||
|
||||
def publish():
|
||||
"""Publish to PyPi"""
|
||||
os.system("python setup.py sdist upload")
|
||||
"""Publish to PyPi"""
|
||||
os.system("python setup.py sdist upload")
|
||||
|
||||
|
||||
if sys.argv[-1] == "publish":
|
||||
publish()
|
||||
sys.exit()
|
||||
publish()
|
||||
sys.exit()
|
||||
|
||||
setup(name='tablib',
|
||||
version=tablib.__version__,
|
||||
description='Python wrapper for Gist API',
|
||||
long_description=open('README.rst').read() + '\n\n' +
|
||||
open('HISTORY.rst').read(),
|
||||
author='Kenneth Reitz',
|
||||
author_email='me@kennethreitz.com',
|
||||
url='http://github.com/kennethreitz/tabbed',
|
||||
packages=['tablib'],
|
||||
license='MIT',
|
||||
classifiers=(
|
||||
"Development Status :: 4 - Beta",
|
||||
"License :: OSI Approved :: MIT License",
|
||||
"Programming Language :: Python",
|
||||
"Programming Language :: Python :: 2.5",
|
||||
"Programming Language :: Python :: 2.6",
|
||||
"Programming Language :: Python :: 2.7",
|
||||
)
|
||||
)
|
||||
setup(
|
||||
name='tablib',
|
||||
version='0.0.4',
|
||||
description='Python wrapper for Gist API',
|
||||
long_description=open('README.rst').read() + '\n\n' +
|
||||
open('HISTORY.rst').read(),
|
||||
author='Kenneth Reitz',
|
||||
author_email='me@kennethreitz.com',
|
||||
url='http://github.com/kennethreitz/tablib',
|
||||
packages=['tablib'],
|
||||
license='MIT',
|
||||
classifiers=(
|
||||
'Development Status :: 4 - Beta',
|
||||
'License :: OSI Approved :: MIT License',
|
||||
'Programming Language :: Python',
|
||||
'Programming Language :: Python :: 2.5',
|
||||
'Programming Language :: Python :: 2.6',
|
||||
'Programming Language :: Python :: 2.7',
|
||||
),
|
||||
entry_points={
|
||||
'console_scripts': [
|
||||
'tabbed = tablib.cli:start',
|
||||
],
|
||||
}
|
||||
)
|
||||
|
||||
+10
-9
@@ -24,6 +24,7 @@ except ImportError, why:
|
||||
|
||||
__all__ = ['Dataset', 'source']
|
||||
|
||||
__name__ = 'tablib'
|
||||
__version__ = '0.0.4'
|
||||
__build__ = '0x000004'
|
||||
__author__ = 'Kenneth Reitz'
|
||||
@@ -167,18 +168,20 @@ class Dataset(object):
|
||||
for j, col in enumerate(row):
|
||||
ws.write(i, j, col)
|
||||
|
||||
doc = xlwt.CompoundDoc.XlsDoc()
|
||||
doc.save(stream, wb.get_biff_data())
|
||||
|
||||
wb.save(stream)
|
||||
return stream.getvalue()
|
||||
|
||||
|
||||
def append(self, row, index=None):
|
||||
# todo: impliment index
|
||||
def append(self, row):
|
||||
"""Adds a row to the end of Dataset"""
|
||||
self._validate(row)
|
||||
self._data.append(tuple(row))
|
||||
|
||||
|
||||
def index(self, i, row):
|
||||
"""Inserts a row at given position in Dataset"""
|
||||
self._validate(row)
|
||||
self._data.insert(i, tuple(row))
|
||||
|
||||
def sort_by(self, key):
|
||||
"""Sorts datastet by given key"""
|
||||
# todo: accpept string if headers, or index nubmer
|
||||
@@ -188,9 +191,7 @@ class Dataset(object):
|
||||
def save(self, filename=None, format=None):
|
||||
"""Saves dataset"""
|
||||
if not format:
|
||||
# set format from filename
|
||||
# format = filename
|
||||
pass
|
||||
format = filename.split('.')[-1].lower() # set format from filename
|
||||
|
||||
if format not in FILE_EXTENSIONS:
|
||||
raise UnsupportedFormat
|
||||
|
||||
@@ -14,5 +14,3 @@ from Column import Column
|
||||
from Formatting import Font, Alignment, Borders, Pattern, Protection
|
||||
from Style import XFStyle, easyxf
|
||||
from ExcelFormula import *
|
||||
|
||||
import CompoundDoc
|
||||
|
||||
@@ -20,7 +20,7 @@ data.append(['kenneth' ,'reitz', 4.3])
|
||||
#print data.json
|
||||
|
||||
data.headers = None
|
||||
#print data.csv
|
||||
print data.xls
|
||||
#print data.yaml
|
||||
#print data.json
|
||||
print data.csv
|
||||
#print len(data.xls)
|
||||
print data.yaml
|
||||
print data.json
|
||||
Reference in New Issue
Block a user