resistics.common.io module

resistics.common.io.checkAndMakeDir(path: str) → None[source]

Check if directory exists and make if not

Parameters
pathstr

Directory path to make

resistics.common.io.checkDirExistence(path: str) → bool[source]

Check if directory exists

..todo:

Should check that it is actually a directory
Parameters
pathstr

Path to check

Returns
outbool

True if directory exists

resistics.common.io.checkFilepath(path: str) → bool[source]

Check if file exists

TODO: Should check that it is actually a file

Parameters
pathstr

Filepath to check

Returns
outbool

True if file exists

resistics.common.io.fileFormatSampleFreq(sampleFreq: float) → str[source]

Provide a consistent way to represent floating numbers in filenames

Parameters
sampleFreqfloat

The sampling frequency

Returns
str

Float converted for string for the purposes of a filename

resistics.common.io.getDataDirectoryFormats() → List[str][source]

Get list of data directory formats

Returns
outList[str]

A list of allowable data directory formats

resistics.common.io.getDataDirsInDirectory(path: str) → List[source]

Get subdirectories in directory

This uses known data formats as defined in getDataDirectoryFormats

Parameters
pathstr

Parent directory path

Returns
dirslist

List of directories containing time data

resistics.common.io.getDirectoryContents(path: str) → Tuple[List, List][source]

Get contents of directory

Includes both files and directories

Parameters
pathstr

Parent directory path

Returns
dirslist

List of directories

fileslist

List of files excluding hidden files

resistics.common.io.getDirsInDirectory(path: str)[source]

Get subdirectories in directory

Excludes hidden files

Parameters
pathstr

Parent directory path

Returns
dirslist

List of subdirectories

resistics.common.io.getFilesInDirectory(path: str) → List[source]

Get files in directory

Excludes hidden files

Parameters
pathstr

Parent directory path

Returns
fileslist

List of files excluding hidden files

resistics.common.io.lineToKeyAndValue(line: str, delim='=') → Tuple[str, str][source]

Helper function to read headers

Parameters
linestr

A string representing a header line

delimstr

The delimeter separating key and value

Returns
keystr

The header key

valstr

The header value

resistics.common.io.makeDir(path: str) → None[source]

Make directory

Parameters
pathstr

Directory path to make

resistics.common.io.removeHiddenFiles(files: List) → List[source]

Remove hidden files from list of files

Hidden files are those which begin with a .

Parameters
fileslist

List of files

Returns
fileslist

List of files with hidden files removed