Python: Difference between revisions
No edit summary |
No edit summary |
||
Line 8: | Line 8: | ||
<syntaxhighlight lang="python"> | <syntaxhighlight lang="python"> | ||
lambda x: x * 2 | lambda x: x * 2 | ||
</syntaxhighlight> | |||
===Read and Write Files=== | |||
====List all files in folder=== | |||
[https://stackoverflow.com/questions/3207219/how-do-i-list-all-files-of-a-directory Reference] | |||
<syntaxhighlight lang="python"> | |||
gazeDir = "Gaze_txt_files" | |||
# List of folders in root folder | |||
gazeFolders = [path.join(gazeDir, x) for x in os.listdir(gazeDir)] | |||
# List of files 2 folders down | |||
gazeFiles = [path.join(x, y) for x in gazeFolders for y in os.listdir(x)] | |||
</syntaxhighlight> | </syntaxhighlight> | ||
=Libraries= | =Libraries= | ||
==Numpy== | ==Numpy== |
Revision as of 18:56, 23 September 2019
Installation
Use Anaconda.
Basic Usage
Lambda Function
lambda x: x * 2
Read and Write Files
=List all files in folder
gazeDir = "Gaze_txt_files"
# List of folders in root folder
gazeFolders = [path.join(gazeDir, x) for x in os.listdir(gazeDir)]
# List of files 2 folders down
gazeFiles = [path.join(x, y) for x in gazeFolders for y in os.listdir(x)]