Simplest way to Open files from Google Drive in Google Colab
You can either watch following tutorial video or read full article
Run following code in notebook
from google.colab import drive
drive.mount('/content/drive')
This code will show you following output
Go through the link, select your google drive account and copy authorization code and paste here in output and press enter.
You can see in the left side in file section, google drive is mounted
Open the file where your data is saved in google drive, right click on the data and copy path
Use that copied path in code to use that data
copied_path = ‘copied path’ #remove ‘content/’ from path then use
data = pd.read_csv(copied_path)
It is very important ro remove ‘content/’ from copied path, for example if your copied path is ‘content/drive/My Drive/collab data/Loan pridiction/PPTrain.csv’ then use ‘drive/My Drive/collab data/Loan pridiction/PPTrain.csv’ as copied path
Watch tutorial video here for any doubt.
Recommended tutorial: How to import Kaggle datasets in colab
Join our Telegram channel for more updates and study resources and discussion