Last active
February 7, 2024 04:00
-
-
Save zhuguoliang/4a65f25675fb215e8bbe8fa92a5bb88c to your computer and use it in GitHub Desktop.
colab list folders
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| # files = os.listdir('/content/drive') | |
| # for fname in files: | |
| # print (fname) | |
| # print ('full path', os.path.join(os.getcwd(), fname)) | |
| def list_files(startpath): | |
| for root, dirs, files in os.walk(startpath): | |
| level = root.replace(startpath, '').count(os.sep) | |
| indent = ' ' * 4 * (level) | |
| print('{}{}/'.format(indent, os.path.basename(root))) | |
| subindent = ' ' * 4 * (level + 1) | |
| for f in files: | |
| print('{}{}'.format(subindent, f)) | |
| list_files('/content/drive/MyDrive/nus-cs4248x/3-neural-nlp/data/corpora') | |
| from google.colab import drive | |
| drive.mount('/content/drive') | |
| import os | |
| os.chdir ("/content/drive/MyDrive/nus-cs4248x/3-neural-nlp/") | |
| print(os.getcwd()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment