diff options
| author | Kenneth Reitz <me@kennethreitz.com> | 2010-09-12 13:48:48 -0400 |
|---|---|---|
| committer | Kenneth Reitz <me@kennethreitz.com> | 2010-09-12 13:50:59 -0400 |
| commit | f188e3dd8779a1c100b097ca44e9739e0d37fa6a (patch) | |
| tree | 41c8c46a3240f87ea4051be935b5baa71bce7f37 /README.rst | |
| parent | 3dff8f5b794ceaff6ab51be79f7425c0b8981f3a (diff) | |
| download | tablib-f188e3dd8779a1c100b097ca44e9739e0d37fa6a.tar.gz | |
Heavy readme update.
Diffstat (limited to 'README.rst')
| -rw-r--r-- | README.rst | 76 |
1 files changed, 52 insertions, 24 deletions
@@ -13,20 +13,20 @@ Tablib: format-agnostic tabular dataset library Tablib is a format-agnostic tabular dataset library, written in Python. -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: :: @@ -34,43 +34,71 @@ 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) - - print data.headers - # >>> ('first_name', 'last_name', 'gpa') + >>> data.append(('Henry', 'Ford', 83)) - 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: :: + + >>> del data[1] +Drumroll please........... -Manipulate rows by index: :: +JSON! :: - del data[0] - print data[0:1] - # >>> [('George', 'Washington', 2.6), ('Henry', 'Ford', 2.3)] + >>> 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 ------------ @@ -87,7 +115,7 @@ Or, if you absolutely must: :: 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_! +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 |
