:author: FrancescAlted :date: 2010-04-20 16:44:41 =================================================== SimpleTable: simple wrapper around the Table object =================================================== Here it is yet another example on how to inherit from the :class:`tables.Table` object so as to build an easy-to-use Table object. Thanks to Brent Pedersen for this one (taken from https://pypi.python.org/pypi/simpletable). :: """ SimpleTable: simple wrapper around pytables hdf5 ------------------------------------------------------------------------------ Example Usage:: >>> from simpletable import SimpleTable >>> import tables # define the table as a subclass of simple table. >>> class ATable(SimpleTable): ... x = tables.Float32Col() ... y = tables.Float32Col() ... name = tables.StringCol(16) # 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 ... 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() >>> tbl.query('(x > 4) & (y < 70)') #doctest: +NORMALIZE_WHITESPACE array([('name_5', 5.0, 50.0), ('name_6', 6.0, 60.0)], dtype=[('name', '|S16'), ('x', '