This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

This module removes some of the boiler-plate code required to use the excellent pytables module to save and access structured data.

Example Usage:

>>> from simpletable import SimpleTable
>>> import tables

define a table as a subclass of simple table.

>>> RGB = tables.Enum(list('RGB'))
>>> class ATable(SimpleTable):
...     x = tables.Float32Col()
...     y = tables.Float32Col()
...     name = tables.StringCol(16)
...     color = tables.EnumCol(RGB, 'R', 'uint8')

instantiate with: args: filename, tablename

>>> tbl = ATable('test_docs.h5', 'atable1')

insert as with pytables:

>>> row = tbl.row
>>> for i in range(50):
...    row['x'], row['y'] = i, i * 10
...    row['name'] = "name_%i" % i
...    # NOTE how we have to manually translate the enum column.
...    row['color'] = RGB['G']
...    row.append()
>>> tbl.flush()

can have the enum cols automatically translated using insert

>>> data = {'x': 1000, 'y': 2000, 'color': 'G', 'name': 'flintstone'}
>>> tbl.insert(data, row)
>>> row.append()
>>> tbl.flush()

there is also insert_many() method with takes an iterable of dicts with keys matching the colunns (x, y, name) in this case.

query the data (query() alias of tables’ readWhere() note that pytables sends back the data with enum cols as they were and does nothing to translate them to their original values.

>>> tbl.query('(x > 4) & (y < 70)') #doctest: +NORMALIZE_WHITESPACE
array([(1, 'name_5', 5.0, 50.0), (1, 'name_6', 6.0, 60.0)],
       dtype=[('color', '|u1'), ('name', '|S16'), ('x', '<f4'), ('y', '<f4')])

get translated enumcols in an iterator with the .q method.

>>> r = tbl.q('x == 1000') # doctest: +NORMALIZE_WHITESPACE
>>> r # doctest: +ELLIPSIS
<generator ...>
>>> list(r)
[{'color': 'G', 'x': 1000.0, 'name': 'flintstone', 'y': 2000.0}]

or use the translate_enum method

>>> for row_with_enum in tbl.query('(x > 4) & (y < 70)'):
...     tbl.translate_enum(row_with_enum)
{'color': 'G', 'x': 5.0, 'name': 'name_5', 'y': 50.0}
{'color': 'G', 'x': 6.0, 'name': 'name_6', 'y': 60.0}

Note that using q or translate_enum will affect performance.

Release History

Release History

0.2.2

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.2

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
simpletable-0.2.2.tar.gz (3.5 kB) Copy SHA256 Checksum SHA256 Source Nov 7, 2009

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting