need to figure out variable length strings

This commit is contained in:
Sandy Walsh 2014-03-20 22:35:50 -03:00
parent 366e84d2fd
commit c31b354bf1
2 changed files with 47 additions and 0 deletions

View File

@ -2,3 +2,12 @@ shoebox
=======
binary data archiving library - supports uploading to object storage
Requires PyTables, which needs (on ubuntu):
sudo apt-get install libhdf5-serial-dev
sudo pip install numpy
sudo pip install numexpr
sudo pip install cython
sudo pip install tables

38
learn_pytables.py Normal file
View File

@ -0,0 +1,38 @@
import random
import tables
class KeyValue(tables.IsDescription):
key = tables.StringCol(itemsize=22, dflt=" ", pos=0)
value = tables.StringCol(itemsize=22, dflt=" ", pos=0)
def make_notification():
return [
("foo[0]", "thing"),
("foo[1]", "stuff"),
("foo[1].child", "ring"),
("foo[2].child[0]", "ding"),
("random", random.random()),
]
# open a file in "w"rite mode
fileh = tables.open_file("storeage.h5", mode = "w")
root = fileh.root
notifications = fileh.create_group(root, "notifications")
notification = fileh.create_table(notifications, "notification", KeyValue)
row = notification.row
for i in xrange(10):
for k, v in make_notification():
row['key'] = k
row['value'] = v
row.append()
notification.flush()
fileh.close()