How to Load a Dataset From the Google Drive to Google Colab

Randula Koralage
Geek Culture
Published in
2 min readMar 28, 2021

--

Photo by Alex Gagareen on Unsplash

When we using google colab for writing data analyzing codes, obviously we need to load our dataset from somewhere. We can use a file picker and load the data set from the PC in the following way, but today I am going to write about, how it can be loaded from our google drive.

Loading data from local disk (PC)

Loading a Dataset from the Google Drive to Google Colab

First of all, you have to mount the google drive to colab. To do that,

Open a colab sheet and write the following code,

Then it will give an output like below

Click the link given. Then you’ll see the usual google account authentication steps and after two steps you’ll see authentication keys for your google drive.

authentication key for google drive

Now add it in the early appeared shell and press enter.

add your token

Now your google drive is mounted.

Now you can read_cvs from google drive. Before that make sure to check your current working directory using the command,

!pwd

check current working directory

My current working directory is /content and the drive is mounted at /content/drive. So to access the dataset, you have to start from /content/drive which is the drive.

My files are located inside a folder called MovieData in the path of, My Drive/ColabDrive/MovieData

So to load the data set simply use,

It’s done.

--

--