mirror of
https://github.com/kennethreitz/tablib.git
synced 2026-06-05 23:10:17 +00:00
Merge branch 'develop'
This commit is contained in:
+2
-1
@@ -1,6 +1,7 @@
|
||||
# application builds
|
||||
build/*
|
||||
dist/*
|
||||
MANIFEST
|
||||
|
||||
# python skin
|
||||
.pyc
|
||||
@@ -13,4 +14,4 @@ profile
|
||||
# pycharm noise
|
||||
.idea
|
||||
.idea/*
|
||||
hi
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
GistAPI.py is written and maintained by Kenneth Reitz and
|
||||
Tablib is written and maintained by Kenneth Reitz and
|
||||
various contributors:
|
||||
|
||||
Development Lead
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
History
|
||||
=======
|
||||
|
||||
0.6.1 (2010-09-12)
|
||||
------------------
|
||||
|
||||
* Packaging hotfixes
|
||||
|
||||
|
||||
0.6.0 (2010-09-11)
|
||||
------------------
|
||||
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
HISTORY.rst
|
||||
README.rst
|
||||
setup.py
|
||||
tabbed
|
||||
tablib/__init__.py
|
||||
tablib/cli.py
|
||||
tablib/core.py
|
||||
tablib/helpers.py
|
||||
+1
-1
@@ -1 +1 @@
|
||||
include HISTORY.rst README.rst tabbed
|
||||
include HISTORY.rst README.rst tabbed LICENSE AUTHORS
|
||||
+74
-26
@@ -12,23 +12,21 @@ Tablib: format-agnostic tabular dataset library
|
||||
|
||||
|
||||
Tablib is a format-agnostic tabular dataset library, written in Python.
|
||||
It is a full python module which doubles as a CLI application for quick
|
||||
dataset conversions.
|
||||
|
||||
Formats supported:
|
||||
Output formats supported:
|
||||
|
||||
- Excel
|
||||
- JSON
|
||||
- YAML
|
||||
- Excel
|
||||
- CSV
|
||||
|
||||
At this time, Tablib supports the **export** of it's powerful Dataset object instances into any of the above formats. Import is underway.
|
||||
|
||||
Please note that tablib *purposefully* excludes XML support. It always will.
|
||||
Note that tablib *purposefully* excludes XML support. It always will.
|
||||
|
||||
|
||||
Features
|
||||
--------
|
||||
Usage
|
||||
-----
|
||||
|
||||
|
||||
Populate fresh data files: ::
|
||||
@@ -36,48 +34,98 @@ Populate fresh data files: ::
|
||||
headers = ('first_name', 'last_name', 'gpa')
|
||||
|
||||
data = [
|
||||
('John', 'Adams', 4.0),
|
||||
('George', 'Washington', 2.6),
|
||||
('John', 'Adams', 90),
|
||||
('George', 'Washington', 67),
|
||||
('Henry', 'Ford', 2.3)
|
||||
]
|
||||
|
||||
data = tablib.Dataset(*data, headers=headers)
|
||||
|
||||
# Establish file location and save
|
||||
data.save('test.xls')
|
||||
|
||||
|
||||
Intelligently add new rows: ::
|
||||
|
||||
data.append('Bob', 'Dylan', 3.2)
|
||||
>>> data.append(('Henry', 'Ford', 83))
|
||||
|
||||
print data.headers
|
||||
# >>> ('first_name', 'last_name', 'gpa')
|
||||
|
||||
|
||||
Slice rows: ::
|
||||
|
||||
print data[0:1]
|
||||
# >>> [('John', 'Adams', 4.0), ('George', 'Washington', 2.6)]
|
||||
>>> print data[:2]
|
||||
[('John', 'Adams', 90), ('George', 'Washington', 67)]
|
||||
|
||||
|
||||
Slice columns by header: ::
|
||||
|
||||
print data['first_name']
|
||||
# >>> ['John', 'George', 'Henry']
|
||||
>>> print data['first_name']
|
||||
['John', 'George', 'Henry']
|
||||
|
||||
Easily delete rows: ::
|
||||
|
||||
Manipulate rows by index: ::
|
||||
>>> del data[1]
|
||||
|
||||
del data[0]
|
||||
print data[0:1]
|
||||
# >>> [('George', 'Washington', 2.6), ('Henry', 'Ford', 2.3)]
|
||||
Drumroll please...........
|
||||
|
||||
JSON! ::
|
||||
|
||||
>>> print data.json
|
||||
[
|
||||
{
|
||||
"last_name": "Adams",
|
||||
"age": 90,
|
||||
"first_name": "John"
|
||||
},
|
||||
{
|
||||
"last_name": "Ford",
|
||||
"age": 83,
|
||||
"first_name": "Henry"
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
YAML! ::
|
||||
|
||||
>>> print data.yaml
|
||||
- {age: 90, first_name: John, last_name: Adams}
|
||||
- {age: 83, first_name: Henry, last_name: Ford}
|
||||
|
||||
CSV... ::
|
||||
|
||||
>>> print data.csv
|
||||
first_name,last_name,age
|
||||
John,Adams,90
|
||||
Henry,Ford,83
|
||||
|
||||
EXCEL!! ::
|
||||
|
||||
>>> open('people.xls').write(data.xls)
|
||||
|
||||
It's that easy.
|
||||
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
To install tablib, simply: ::
|
||||
|
||||
$ pip install tablib
|
||||
|
||||
Or, if you absolutely must: ::
|
||||
|
||||
$ easy_install tablib
|
||||
|
||||
|
||||
Contribute
|
||||
----------
|
||||
|
||||
If you'd like to , simply fork `the repository`_, commit your changes, and send a pull requests. Make sure you add yourself to AUTHORS_.
|
||||
|
||||
|
||||
Roadmap
|
||||
-------
|
||||
- Import datasets from CSV, JSON, YAML
|
||||
- Release CLI Interface
|
||||
- Auto-detect import format
|
||||
- Plugin support
|
||||
- Add possible other exports (SQL?)
|
||||
- Possibly plugin-ify format architecture
|
||||
- Plugin support
|
||||
|
||||
.. _`the repository`: http://github.com/kennethreitz/tablib
|
||||
.. _AUTHORS: http://github.com/kennethreitz/tablib/blob/master/AUTHORS
|
||||
Vendored
-20
@@ -5,23 +5,3 @@ def scrub():
|
||||
""" Death to the bytecode! """
|
||||
local("rm -fr dist build")
|
||||
local("find . -name \"*.pyc\" -exec rm '{}' ';'")
|
||||
|
||||
def test():
|
||||
""" Test parsing! """
|
||||
local("rm output/*")
|
||||
local("./strata.py --nsanity_files 'strata/tests/samples/nsanity' -d")
|
||||
|
||||
def build():
|
||||
""" Build application"""
|
||||
pass
|
||||
|
||||
def init():
|
||||
""" Initialize Environment """
|
||||
# TODO: Possibly add Virtual Environment?
|
||||
local("sudo pip install -r REQUIREMENTS")
|
||||
|
||||
if __name__ == '__main__':
|
||||
# TODO: Remove (for testing purposes)
|
||||
# TODO: [Possibly] add doctests
|
||||
test()
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import os
|
||||
import sys
|
||||
@@ -32,7 +33,7 @@ setup(
|
||||
'License :: OSI Approved :: MIT License',
|
||||
'Programming Language :: Python',
|
||||
# 'Programming Language :: Python :: 2.5',
|
||||
# 'Programming Language :: Python :: 2.6',
|
||||
'Programming Language :: Python :: 2.6',
|
||||
'Programming Language :: Python :: 2.7',
|
||||
),
|
||||
# entry_points={
|
||||
|
||||
Reference in New Issue
Block a user