Download Kaggle Dataset to Google Drive

Utshab Kumar Ghosh
1 min readApr 21, 2022

--

At First, mount your drive to Colab Notebook.

from google.colab import drive
drive.mount(‘/content/drive’)

  1. Go to path where you want to download the dataset in your drive. Mine was:

%cd /content/drive/My Drive/Colab_Notebooks/dataset1

2. Take your Token from Kaggle. For this:

  • Go to My Account (Not My Profile).
  • Go to API Section and click on Create New API Token.
  • Download the token, which will be saved as a .json file (e.g. kaggle.json).

3. Use this code to upload API Token from Kaggle:

from google.colab import files
files.upload()

4. Run this 4 lines of code:

!mkdir -p ~/.kaggle
!cp kaggle.json ~/.kaggle/
!chmod 600 ~/.kaggle/kaggle.json
!rm kaggle.json

5. Go to your desired Dataset page. Agree with the terms and then copy the API Command. (Note: Give “!” before kaggle). e.g.:

!kaggle datasets download -d biaiscience/dogs-vs-cats

6. (optional) To unzip files:

from zipfile import ZipFile
file_name=”/content/drive/My Drive/Colab_Notebooks/dataset1/dogs-vs-cats.zip”
with ZipFile(file_name,’r’) as zip:
zip.extractall()
print(‘Done’)

Image taken from:
https://vocal.media/01/easy-downloading-kaggle-data-to-google-drive

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Utshab Kumar Ghosh
Utshab Kumar Ghosh

Written by Utshab Kumar Ghosh

Passionate about Python, Image Processing, Computer Vision, Data Science, Machine Learning, and Deep Learning.

No responses yet

Write a response