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.
Use the Same google account for Colab and Gdrive, to avoid error.
open new notebook in colab and execute the below code
from google.colab import drive
drive.mount('/content/drive')
visit the link and give access permission
then copy the code from the link and paste it in the colab page
from colab, go to gdrive path using below command
% cd drive/My\ Drive/
then use colabs as using terminal with ! symbol before the commands
!mkdir sample
you can view the modifications from side panel on left side
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With