Skip to content

Instantly share code, notes, and snippets.

@haruiz
Created July 20, 2019 19:25
Show Gist options
  • Save haruiz/c39398093b3009a51b1b5e209958461d to your computer and use it in GitHub Desktop.
Save haruiz/c39398093b3009a51b1b5e209958461d to your computer and use it in GitHub Desktop.
from google.colab import drive
import os
def create_folder_gdrive(folder: str):
drive2mount = "/gdrive"
drive.mount(drive2mount, force_remount=True)
root_folder = os.path.join(drive2mount,"My Drive", folder)
os.makedirs(root_folder,exist_ok=True)
return root_folder
root_folder = create_folder_gdrive("myfolder")
test_file =os.path.join(root_folder, 'foo.txt')
with open(test_file, 'w') as f:
f.write('Hello Google Drive!')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment