示例#1
0
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()
示例#2
0
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()
示例#3
0
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()
    
示例#4
0
文件: utils.py 项目: PKMap/nilmtk
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')
示例#5
0
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')
示例#6
0
 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()
示例#8
0
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()