forked from LeonardoViotti/tdl-notebook
-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.py
30 lines (20 loc) · 764 Bytes
/
utils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import os
from glob import glob
import pandas as pd
def find_path(file_name, path):
""" Searches [path] for [file_name]
Args:
file_name (str): File name with extention
path (str): Relative/Absolute search dir path
Returns:
(str): Absolute filepath for [file_name]
"""
files = []
for dir,_,_ in os.walk(path):
files.extend(glob(os.path.join(dir,file_name)))
assert len(files) == 1, f"Multiple files found for {file_name}! {files}"
return files[0]
def create_relative_path(scores_df):
scores_df = scores_df.drop('Unnamed: 0', axis = 1)
scores_df['relative_path'] = scores_df['file'].str.split('/', expand = True).iloc[:,-2] + '/' + scores_df['clip']
return scores_df