Merge branch 'master' into master

This commit is contained in:
Jean Jordaan
2019-03-03 13:29:21 +07:00
committed by GitHub
304 changed files with 782 additions and 102041 deletions
+40 -27
View File
@@ -21,14 +21,18 @@ Output formats supported:
- Excel (Sets + Books)
- JSON (Sets + Books)
- YAML (Sets + Books)
- Pandas DataFrames (Sets)
- HTML (Sets)
- Jira (Sets)
- TSV (Sets)
- OSD (Sets)
- ODS (Sets)
- CSV (Sets)
- DBF (Sets)
Note that tablib *purposefully* excludes XML support. It always will. (Note: This is a joke. Pull requests are welcome.)
If you're interested in financially supporting Kenneth Reitz open source, consider `visiting this link <https://cash.me/$KennethReitz>`_. Your support helps tremendously with sustainability of motivation, as Open Source is no longer part of my day job.
Overview
--------
@@ -71,13 +75,13 @@ Intelligently add new columns: ::
Slice rows: ::
>>> print data[:2]
>>> print(data[:2])
[('John', 'Adams', 90), ('George', 'Washington', 67)]
Slice columns by header: ::
>>> print data['first_name']
>>> print(data['first_name'])
['John', 'George', 'Henry']
Easily delete rows: ::
@@ -93,51 +97,60 @@ JSON!
+++++
::
>>> print data.json
[
{
"last_name": "Adams",
"age": 90,
"first_name": "John"
},
{
"last_name": "Ford",
"age": 83,
"first_name": "Henry"
}
]
>>> print(data.export('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}
>>> print(data.export('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
>>> print(data.export('csv'))
first_name,last_name,age
John,Adams,90
Henry,Ford,83
EXCEL!
++++++
::
>>> with open('people.xls', 'wb') as f:
... f.write(data.xls)
>>> with open('people.xls', 'wb') as f:
... f.write(data.export('xls'))
DBF!
++++
::
>>> with open('people.dbf', 'wb') as f:
... f.write(data.dbf)
... f.write(data.export('dbf'))
Pandas DataFrame!
+++++++++++++++++
::
>>> print(data.export('df')):
first_name last_name age
0 John Adams 90
1 Henry Ford 83
It's that easy.
@@ -147,7 +160,7 @@ Installation
To install tablib, simply: ::
$ pip install tablib
$ pip install tablib[pandas]
Make sure to check out `Tablib on PyPi <https://pypi.python.org/pypi/tablib/>`_!