resurfemg.data_connector.file_discovery module¶
Copyright 2022 Netherlands eScience Center and University of Twente Licensed under the Apache License, version 2.0. See LICENSE for details.
This file contains functions to automatically find specified files and folders.
- resurfemg.data_connector.file_discovery.find_files(base_path, file_name_regex=None, extension_regex=None, folder_levels=None, verbose=True)¶
Find files with the file name and extension according to filename pattern file_name_regex.`extension_regex` starting from the provided base_path according to the provided folder_leves. If folder_levels is None, all files matching the name pattern included, no matter the data organisation. ————————————————————————— :param base_path: Path to starting directory :type base_path: str :param file_name_regex: file name pattern, see Python Regex docs :type file_name_regex: str :param extension_regex: file extension pattern, see Python Regex docs :type extension_regex: str :param folder_levels: data directory organisation, e.g. [‘patient’, ‘date’] :type folder_levels: list(str) or str :param verbose: Provide feedback about non-included files :type verbose: bool
- Returns files:
Matching file paths tabled by the folder_levels
- Rtype files:
pd.DataFrame
- resurfemg.data_connector.file_discovery.find_folders(base_path, folder_levels=None, verbose=True)¶
Find folders up to the depth of the provided folder_levels starting from the provided base_path. If folder_levels is None, all folders in the provided are included, no matter the data organisation. ————————————————————————— :param base_path: Path to starting directory :type base_path: str :param folder_levels: data directory organisation, e.g. [‘patient’, ‘date’] :type folder_levels: list(str) or str :param verbose: Provide feedback about non-included files :type verbose: bool
- Returns folders:
Folder paths tabled by the folder_levels
- Rtype folders:
pd.DataFrame