Skip to content

Instantly share code, notes, and snippets.

View niket-agrawal's full-sized avatar
🤗
Master's in Cognitive Neuroscience

Niket Agrawal niket-agrawal

🤗
Master's in Cognitive Neuroscience
View GitHub Profile
@niket-agrawal
niket-agrawal / file_access.py
Last active July 17, 2019 05:20
[Python]__ Access all file types of particular extension from any directory path
import os
#used for accessing the particular folders
folders = ['Patient1', 'Patient2','Patient3']
#uncomment the following line to access all folders present in the directory
#folders = os.listdir("C:\\Users\\niket\\Desktop\\Download Dustbin\\main_folder")
def load_from_folder(folder):
images = []
sub_path = "C:\\Users\\niket\\Desktop\\Download Dustbin\\main_folder\\" + folder
for filename in os.listdir(sub_path):
if any([filename.endswith(x) for x in ['.jpg', '.jpeg']]):