expand_file_path()

audformat.utils.expand_file_path(index, root)[source]

Expand path in index with root.

It applies os.path.normpath() to the provided path root, adds a file separator at its end and puts it in front of the file path in the index.

Parameters
Return type

Index

Returns

index with root added to file path

Raises

ValueError – if index is not conform to table specifications

Examples

>>> expand_file_path(filewise_index(["f1", "f2"]), "/a")
Index(['/a/f1', '/a/f2'], dtype='string', name='file')
>>> expand_file_path(filewise_index(["f1", "f2"]), "./a")
Index(['a/f1', 'a/f2'], dtype='string', name='file')