fastwater.general.fileTools module

Generic file manipulation tools.

fastwater.general.fileTools.generateGlobalAttributes(titleStr)[source]

Generate a generic global attributes dictionary for adding meta data to a data dictionary.

Parameters

titleStr (str) – a string defining the data set being attributed.

Returns

globalAttr – a dictionary containing generic data about the dataset creation.

Return type

dict

fastwater.general.fileTools.getListOfFiles(filePath, searchStr='')[source]

Get a list of file from a directory based on a search string.

Parameters
  • filePath (str) – path string to directory to be searched for files.

  • searchStr (str) – sub-string fragment that can be used to identify a file or set of files.

Returns

files – a list of the file names containing the search string.

Return type

list, str

fastwater.general.fileTools.loadMatFile(fileName)[source]

Load a matlab data structure from an *.mat file.

Parameters

fileName (str) – path string to file to the mat be loaded into a python dictionary.

Returns

matData – python dictionary containing the matlab data structure.

Return type

dict

fastwater.general.fileTools.loadmat(filename)[source]

this function should be called instead of direct spio.loadmat as it cures the problem of not properly recovering python dictionaries from mat files. It calls the function check keys to cure all entries which are still mat-objects

from: StackOverflow

fastwater.general.fileTools.mat2dict(fileName)[source]

Load an *.mat file into a dictionary structure

Parameters

fileName (str) – path string to file to the mat be loaded into a python dictionary.

Returns

dataDict – python dictionary containing the matlab formatted data structure.

Return type

dict

fastwater.general.fileTools.print_mat_nested(d, indent=0)[source]

Pretty print nested structures from .mat files Inspired by: StackOverflow