pyCGM2.Utils#

files functions#

concatenateExcelFiles(DATA_PATH_OUT, ...)

Concatenate multiple Excel files into a single Excel file.

copyPaste(src, dst)

Copy and paste a file from a source to a destination.

copyPasteDirectory(src, dst)

Copy and paste a directory from a source to a destination.

copySessionFolder(folderPath, folder2copy, ...)

Copy a session folder, optionally including only selected files.

createDir(fullPathName)

Create a new directory.

deleteDirectory(dir)

Delete a directory.

getC3dFiles(path[, text, ignore])

Retrieve all C3D files from a directory, optionally filtering by text within filenames.

getDirname(fullname)

Extract the directory path from a full path.

getDirs(folderPath)

Get all subdirectories within a folder.

getFileCreationDate(file)

Get the creation date of a file.

getFilename(fullname)

Extract the filename from a full path.

getFiles(path, extension[, ignore, raiseFlag])

Retrieve all files with a specific extension from a directory.

getIKweightSet(DATA_PATH, ikwf)

Retrieve marker weights for kinematic fitting from a specified file.

getMp(mpInfo[, resetFlag])

Return required and optional anthropometric parameters from a given dictionary.

getMpFileContent(DATA_PATH, file, subject)

Retrieve anthropometric data from a specified file.

getTranslators(DATA_PATH[, translatorType])

Retrieve CGM marker translators from a specified file.

is_json(s)

Check if a string is valid JSON.

is_yaml(s)

Check if a string is valid YAML.

loadAnalysis(path, FilenameNoExt)

Load a pyCGM2 analysis instance from a file.

loadModel(path, FilenameNoExt)

Load a pyCGM2 model instance from a file.

loadModelSettings(DATA_PATH, ...)

Load pyCGM2 model settings from a specified file.

loadMp(path, filename)

Load a set of anthropometric parameters (mp file).

loadSettings(DATA_PATH, settingFile[, subfolder])

Load settings from a specified file.

openFile(path, filename)

Open a JSON or YAML file and return its contents as a dictionary.

openJson(path, filename)

Open a JSON file and return its contents as a dictionary.

openPickleFile(path, filename)

Open a serialized (pickle) file and return its contents.

openYaml(path, filename)

Open a YAML file and return its contents as a dictionary.

readContent(stringContent)

Read a string content in JSON or YAML format and return it as a dictionary.

readXml(DATA_PATH, filename)

Read an XML file and parse its contents.

renameFile(fileToRename, renamedFile)

Rename a file.

saveAnalysis(analysisInstance, path, ...)

Save a pyCGM2 analysis instance to a file.

saveJson(path, filename, content[, ensure_ascii])

Save a dictionary as a JSON file.

saveModel(model, path, FilenameNoExt)

Save a pyCGM2 model instance to a file.

saveMp(mpInfo, model, DATA_PATH, mpFilename)

Save anthropometric parameters as a JSON file.

savePickleFile(instance, path, filename)

Serialize an object and save it as a pickle file.

saveYaml(path, filename, content)

Save a dictionary as a YAML file.

try_as(loader, s, on_error)

Attempt to parse a string with a given loader and catch specific errors.

utils functions#

checkSimilarElement(listData)

Check if all elements in a list are similar.

getSimilarElement(listData)

Get a similar element from a list.

homogeneizeArguments(argv, kwargs)

Homogenize arguments by merging positional and keyword arguments into a single dictionary.

isInRange(val, min, max)

Check if a value is within a specified range.

str(unicodeVariable)

Encode a unicode variable to a specified encoding format.

toBool(text)

Convert a text string to a boolean value.