I want to download data from google drive link shared by someone using google colab. I am a new user of colab and I don't know how to do that. the links are
x_train: https://drive.google.com/open?id=1cUaIEd9-MLJHFGjLz5QziNvfBtYygplX
y_train: https://drive.google.com/open?id=1hv24Ufiio9rBeSqgnNoM3dr5sVGwOmBy
x_test: https://drive.google.com/open?id=1AH9lKHT5P2oQLz8SGMRPWs_M9wIM2ZRH
y_test: https://drive.google.com/open?id=1i4_azocSDuU3TcDf3OSHO1vF0D5-xMU6
Thanks in advance
You can use the upload option at the top of the Files explorer to upload any file(s) from your local machine to Google Colab. Step 2: Click the upload icon and select the file(s) you wish to upload from the “File Upload” dialog window.
Drag files into Google Drive On your computer, go to drive.google.com. Open or create a folder. To upload files and folders, drag them into the Google Drive folder.
Executing the following two lines of code will import the data into Colab: import pandas as pd pd.read_csv('/content/gdrive/My Drive/sample data/sample.csv') Importing Data from Local System. Step1 Run the following two lines of code to import data from the local system. from google.colab import files uploaded = files.upload()
Create a shortcut to this file in your Google Drive (right-click on file -> "Add shortcut to Disk") Mount your Google drive in Colab notebook (click buttons: "Files" -> "Mount Drive") Now you can access this file via your shortcut for !unzip/np.load/ ...
Click on the arrow on the left and you will find the data structure. For your easy usage, just save the below code snippet and paste it into the Google Colab and you can mount your Google Drive to the notebook easily. In this section I will share with you my experience in downloading dataset from Kaggle and other competition.
Step 1 First, go to your Google Colab then type the below: If you are able to access Google Drive, your google drive files should be all under: In this section I will share with you my experience in downloading dataset from Kaggle and other competition. Visit www.kaggle.com ⇨ login ⇨ My Account ⇨ Create New API Token
You can use gdown
if the file is shared publicly.
!gdown --id 1cUaIEd9-MLJHFGjLz5QziNvfBtYygplX
If it's shared to you only, you need to use pydrive
# Install the PyDrive wrapper & import libraries.
from pydrive.auth import GoogleAuth
from pydrive.drive import GoogleDrive
from google.colab import auth
from oauth2client.client import GoogleCredentials
# Authenticate and create the PyDrive client.
auth.authenticate_user()
gauth = GoogleAuth()
gauth.credentials = GoogleCredentials.get_application_default()
drive = GoogleDrive(gauth)
file_id = '1cUaIEd9-MLJHFGjLz5QziNvfBtYygplX'
downloaded = drive.CreateFile({'id':file_id})
downloaded.FetchMetadata(fetch_all=True)
downloaded.GetContentFile(downloaded.metadata['title'])
If they share a folder, it's too long so I made it short in my library.
!pip install kora
from kora import drive
drive.download_folder('1HvIeNhqtFVllXFWzH5NawDdnIfgGDwCK')
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