From c890ea93cb39113ecc4c296c10db6644be2a8647 Mon Sep 17 00:00:00 2001 From: Jim Paris Date: Fri, 28 Dec 2012 17:17:41 -0500 Subject: [PATCH] WIP switching away from PyTables --- nilmdb/bulkdata.py | 69 +++++++++++++++++++++++++++------------------- nilmdb/nilmdb.py | 2 +- 2 files changed, 41 insertions(+), 30 deletions(-) diff --git a/nilmdb/bulkdata.py b/nilmdb/bulkdata.py index 9719d14..e0717c3 100644 --- a/nilmdb/bulkdata.py +++ b/nilmdb/bulkdata.py @@ -7,13 +7,17 @@ from nilmdb.printf import * import tables import os import sys +import re class BulkData(object): def __init__(self, basepath): self.basepath = basepath + self.root = self.basepath + "/data" + + # Make root path + if not os.path.isdir(self.root): + os.mkdir(self.root) - h5filename = os.path.abspath(self.basepath + "/data.h5") - self.h5file = tables.openFile(h5filename, "a", "NILM Database") self.opened = True self.tablecache = {} @@ -24,12 +28,10 @@ class BulkData(object): self.basepath) def close(self): - self.h5file.close() for table in self.tablecache.values(): table.close() del self.opened - def create(self, path, layout_name): """ path: path to the data (e.g. '/newton/prep'). @@ -47,43 +49,57 @@ class BulkData(object): if group == '': raise ValueError("invalid path") - # Get description + # Get layout, and build format string for struct module try: - # Build PyTables description layout = nilmdb.layout.get_named(layout_name) - desc = {} - desc['timestamp'] = tables.Col.from_type('float64', pos=0) + desc = '