/usr/share/doc/python-tables-doc/examples/split.py is in python-tables-doc 3.1.1-0ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | """Use the H5FD_SPLIT driver to store metadata and raw data in separate files.
In this example, we store the metadata file in the current directory and
the raw data file in a subdirectory.
"""
import os
import errno
import numpy
import tables
FNAME = "split"
DRIVER = "H5FD_SPLIT"
RAW_DIR = "raw"
DRIVER_PROPS = {
"driver_split_raw_ext": os.path.join(RAW_DIR, "%s-r.h5")
}
DATA_SHAPE = (2, 10)
class FooBar(tables.IsDescription):
tag = tables.StringCol(16)
data = tables.Float32Col(shape=DATA_SHAPE)
try:
os.mkdir(RAW_DIR)
except OSError as e:
if e.errno == errno.EEXIST:
pass
with tables.open_file(FNAME, mode="w", driver=DRIVER, **DRIVER_PROPS) as f:
group = f.create_group("/", "foo", "foo desc")
table = f.create_table(group, "bar", FooBar, "bar desc")
for i in range(5):
table.row["tag"] = "t%d" % i
table.row["data"] = numpy.random.random_sample(DATA_SHAPE)
table.row.append()
table.flush()
|