Skip to main content

Import, filter and export tabular data with Python easily

Project description

outputty is a simple Python library that helps you importing, filtering and exporting data. It is composed by a main Table class and a lot of plugins that helps importing and exporting data to/from Table (in future we’ll have filtering plugins). You can write your own plugin easily (see outputty/plugin_*.py for examples).

Some examples of plugins are: CSV, text, HTML and histogram.

Example

Code time!

>>> from outputty import Table
>>> my_table = Table(headers=['name', 'age']) # headers are the columns
>>> my_table.append(('Alvaro Justen', 24)) # a row as tuple
>>> my_table.append({'name': 'Other User', 'age': 99}) # a row as dict
>>> print my_table # a text representation of Table
+---------------+-----+
|      name     | age |
+---------------+-----+
| Alvaro Justen |  24 |
|    Other User |  99 |
+---------------+-----+

>>> print 'First row:', my_table[0] # Table is indexable
First row: [u'Alvaro Justen', 24]

>>> print 'Sum of ages:', sum(my_table['age']) # you can get columns too
Sum of ages: 123

>>> my_table.write('csv', 'my-table.csv') # CSV plugin will save its contents in a file
>>> # let's see what's in the file...
>>> print open('my-table.csv').read()
"name","age"
"Alvaro Justen","24"
"Other User","99"

>>> # let's use HTML plugin!
>>> print my_table.write('html') # without filename `write` will return a string
<table>
  <thead>
    <tr class="header">
      <th>name</th>
      <th>age</th>
    </tr>
  </thead>
  <tbody>
    <tr class="odd">
      <td>Alvaro Justen</td>
      <td>24</td>
    </tr>
    <tr class="even">
      <td>Other User</td>
      <td>99</td>
    </tr>
  </tbody>
</table>

The Table class have a lot of other features. To learn more (by examples), read outputty tutorial and see examples. Enjoy! :-)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

outputty-0.1.0.tar.gz (25.9 kB view details)

Uploaded Source

File details

Details for the file outputty-0.1.0.tar.gz.

File metadata

  • Download URL: outputty-0.1.0.tar.gz
  • Upload date:
  • Size: 25.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for outputty-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0c92ce1f5c4fc29ab9e951ff50ecaec8acb0fe582a247c6cc00a8be979432f14
MD5 0a16a615fa2fccdf1ed751e9bff1201a
BLAKE2b-256 4bec605fe59627eab86ed88ce91904bafb56d1d027a4505d2d07af8110a13b4e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page