Search code examples
pythonpython-3.xgoogle-colaboratorypydrive

Moving Folder from Google Colab to Google Drive


I am using Google Colab for Machine Learning. Many times I need to download solution CSV using Google Drive using Pydrive. As shown below

from pydrive.auth import GoogleAuth
from pydrive.drive import GoogleDrive
from google.colab import auth
from oauth2client.client import GoogleCredentials

auth.authenticate_user()
gauth = GoogleAuth()
gauth.credentials = GoogleCredentials.get_application_default()
drive = GoogleDrive(gauth)

uploaded = drive.CreateFile({'title': 'dogsVScats.csv'})
uploaded.SetContentFile('dogsVScats.csv')
uploaded.Upload()
print('Uploaded file with ID {}'.format(uploaded.get('id')))

How to replicate this same process fora folder. Not File.


Solution

  • Compress your entire folder and download the compressed file instead. In fact I think it would speed your download. I found that p7zip works flawlessly with Colab.