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 pathroot
, adds a file separator at its end and puts it in front of the file path in the index.- Parameters
index (
Index
) – index conform to table specificationsroot (
str
) – relative or absolute path added in front of the index file path
- Return type
- 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')