im retriving folders of a directry like this: with ThreadPoolExecutor() as executor:…
- User
im retriving folders of a directry like this: with ThreadPoolExecutor() as executor: futures = []
# List of folders to iterate through folders = [d for d in Path(base_directory_path).iterdir() if d.is_dir()] # Loop through each folder and then through each CSV file within them for folder in folders: for file_path in folder.glob('*.csv'): futures.append(executor.submit(calculate_talib, file_path)) for future in as_completed(futures): pass # Future results or exceptions can be processed here if neededhow can i access name of floder in each iteration?
- Assistant
To access the name of the folder for each iteration while processing your files in parallel, you can slightly modify your task submission approach by including the folder name along with the file path in your call to the
calculate_talibfunction. If the function does not currently accept the folder name as an argument, you will need to adjust its signature accordingly.