Files
Files¶
-
best.files.create_folder(PATH_TO_CREATE)¶ Creates a folder on PATH_TO_CREATE position.
-
best.files.get_files(path, endings=None, creation_time=False)¶ File list generator.
For each file in path directory and subdirectories with endings from endings_tuple returns path in a list variable
path is a string, the path to the directory where you wanna search specific files.
endings_tuple is a tuple of any length
The function returns paths to all files in folder and files in all subfolders as well.
from best.files import get_files import pandas as pd path = "root/data" files_list = get_files(path, ('.jpg', '.jpeg')) files_pd = pd.DataFrame(files_list) def get_FID(x): temp = x['path'].split('\') return temp[len(temp) - 1][0:-4] files_pd = files_pd.rename(columns={0: "path"}) files_pd['fid'] = files_pd.apply(lambda x: get_FID(x), axis=1)
-
best.files.get_folders(path)¶ Returns sub-folders present in the folder specified by the path.
-
best.files.remove_folder(PATH_TO_REMOVE)¶ Creates a folder on PATH_TO_CREATE position.
-
best.files.split_files(file_paths, ratio=0.5)¶ Randomly shuffles list of files and splits given by the ratio.