Jump to content

Python: Difference between revisions

24 bytes added ,  7 April 2021
Line 113: Line 113:
[https://stackoverflow.com/questions/3207219/how-do-i-list-all-files-of-a-directory Reference]
[https://stackoverflow.com/questions/3207219/how-do-i-list-all-files-of-a-directory Reference]
<syntaxhighlight lang="python">
<syntaxhighlight lang="python">
gazeDir = "Gaze_txt_files"
gaze_directory = "Gaze_txt_files"
# List of folders in root folder
# List of folders in root folder
gazeFolders = [path.join(gazeDir, x) for x in os.listdir(gazeDir)]
gaze_folders = [path.join(gaze_directory, x) for x in os.listdir(gaze_directory)]
# List of files 2 folders down
# List of files 2 folders down
gazeFiles = [path.join(x, y) for x in gazeFolders for y in os.listdir(x)]
gaze_files = [path.join(x, y) for x in gaze_folders for y in os.listdir(x)]
</syntaxhighlight>
</syntaxhighlight>