anypytools.datautils#

Created on Mon Jan 16 11:40:42 2012.

@author: mel

Module Contents#

Functions#

anydatah5_generator

Create a generator which opens anydata.h5 files.

anyoutputfile_generator

Create a generator which opens AnyOutput files.

read_anyoutputfile

Read an AnyOutput file.

API#

anypytools.datautils.anydatah5_generator(folder=None, match='.*(\\.h5)')#

Create a generator which opens anydata.h5 files.

Parameters:
  • folder (str, optional) – path of the directory to look for anydata.h5 files. Defaults is the current working directory

  • match (str) – regular expression to match with filenames. Default is to include file ending with .h5 ‘.*(.h5)’

Yields:
  • h5py_file (array_like) – a h5_py file opened with anypytools.h5py_wrapper

  • filename (str) – name of the file from which the data was read

Examples

>>> for (h5, filename) in anydatah5_generator():
        print(h5)
anypytools.datautils.anyoutputfile_generator(folder=None, match='.*\\.(csv|txt)')#

Create a generator which opens AnyOutput files.

Parameters:
  • folder (str, optional) – path of the directory to look for AnyOutput files. Defaults is the current working directory

  • match (str) – regular expression to match with filenames. Default is to include file ending with .csv or .txt ‘.*(.csv|.txt)’

Yields:
  • data (array_like) – data collumns in the anyoutput file

  • header (list) – list of the collumn names

  • constants (dict) – mapping with constants found in the file

  • filename (str) – name of the file from which the data was read

Examples

>>> for (data, header, const, fn) in anyoutputfile_generator():
        print(fn)
        print(header)
        print(data.shape)
anypytools.datautils.read_anyoutputfile(filepath)#

Read an AnyOutput file.

Parameters:

filepath (str)

Returns:

  • data (array_like) – data collumns in the anyoutput file

  • header (list) – list of the collumn names

  • constants (dict) – mapping with constants found in the file