Last active
May 25, 2025 01:38
-
-
Save janusson/1c14bbbb12bd2b72f4c2a9334d248292 to your computer and use it in GitHub Desktop.
This function navigates through the specified directory and its subdirectories to find all files that end with .csv. It then returns a list containing the relative paths of these files.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
def get_csv_file_paths(directory_path) -> list: | |
""" | |
Retrieves the relative paths of all CSV files in the specified directory. | |
Args: | |
directory_path (str): Path to the directory containing CSV files. | |
Returns: | |
list: List of relative file paths for CSV files. | |
""" | |
return [os.path.join(root, file) for root, _, files in os.walk(directory_path) for file in files if file.lower().endswith('.csv')] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Get CSV File Paths Description
This function navigates through the specified directory and its subdirectories to find all files that end with .csv. It then returns a list containing the relative paths of these files.
get_csv_file_paths.py