def test_convert_random_dataset(): input_filepath = 'data/random.h5' output_filepath = 'data/random_csv' if os.path.isdir(output_filepath): shutil.rmtree(output_filepath) input_store = HDFDataStore(input_filepath) output_store = CSVDataStore(output_filepath) convert_datastore(input_store, output_store) input_store.close() output_store.close()
def test_convert_random_dataset(): input_filepath = r'C:\Users\CVLab\Documents\nilm\nilmtk\data\random.h5' output_filepath = r'C:\Users\CVLab\Documents\nilm\nilmtk\data\random_csv' if os.path.isdir(output_filepath): shutil.rmtree(output_filepath) input_store = HDFDataStore(input_filepath) output_store = CSVDataStore(output_filepath) convert_datastore(input_store, output_store) input_store.close() output_store.close()
def test_convert_random_dataset(): input_filepath = 'data/random.h5' output_filepath = 'data/random_csv' if os.path.isdir(output_filepath): shutil.rmtree(output_filepath) input_store=HDFDataStore(input_filepath) output_store=CSVDataStore(output_filepath) convert_datastore(input_store, output_store) input_store.close() output_store.close()
def get_datastore(filename, format=None, mode='r'): """ Parameters ---------- filename : string format : 'CSV' or 'HDF', default: infer from filename ending. mode : 'r' (read-only), 'a' (append) or 'w' (write), default: 'r' Returns ------- metadata : dict """ if not format: if filename.endswith(".h5"): format = "HDF" elif filename.endswith(".csv"): format = "CSV" if filename is not None: if format == "HDF": return HDFDataStore(filename, mode) elif format == "CSV": return CSVDataStore(filename) else: raise ValueError('format not recognised') else: ValueError('filename is None')
def get_datastore(filename, format, mode='a'): """ Parameters ---------- filename : string format : 'CSV' or 'HDF' mode : 'a' (append) or 'w' (write), optional Returns ------- metadata : dict """ if filename is not None: if format == 'HDF': return HDFDataStore(filename, mode) elif format == 'CSV': return CSVDataStore(filename) else: raise ValueError('format not recognised') else: ValueError('filename is None')
def setUpClass(cls): filename = join(data_dir(), 'random_csv') cls.datastore = CSVDataStore(filename) cls.keys = ['/building1/elec/meter{:d}'.format(i) for i in range(1, 6)]
from nilmtk.datastore import HDFDataStore, CSVDataStore from nilmtk.datastore.datastore import convert_datastore import os import shutil input_filepath = 'data/random.h5' output_filepath = 'data/random_csv' if os.path.isdir(output_filepath): shutil.rmtree(output_filepath) input_store=HDFDataStore(input_filepath) output_store=CSVDataStore(output_filepath) convert_datastore(input_store, output_store) input_store.close() output_store.close()
from nilmtk.datastore import HDFDataStore, CSVDataStore from nilmtk.datastore.datastore import convert_datastore import os import shutil input_filepath = 'data/random.h5' output_filepath = 'data/random_csv' if os.path.isdir(output_filepath): shutil.rmtree(output_filepath) input_store = HDFDataStore(input_filepath) output_store = CSVDataStore(output_filepath) convert_datastore(input_store, output_store) input_store.close() output_store.close()