Python: Difference between revisions

From David's Wiki
No edit summary
No edit summary
Line 10: Line 10:
</syntaxhighlight>
</syntaxhighlight>


===Read and Write Files===
==Filesystem Read and Write==
====List all files in folder===
===List all files in a folder===
[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">

Revision as of 18:56, 23 September 2019


Installation

Use Anaconda.

Basic Usage

Lambda Function

lambda x: x * 2

Filesystem Read and Write

List all files in a folder

Reference

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)]

Libraries

Numpy