Getting kaggle dataset into colab

Adarsha Regmi
2 min readAug 12, 2021

Everyone once must have tried to directly use the dataset from kaggle without downloading the datasets from the kaggle. For any data science lover colab is the most easiest place to work on. The free tier provided for Colab certainly helps the developers around the globe though she\he is an alien.

Requirements:

must have google and kaggle account

must know to spell goooogle if not follow below::

watched this

okay!! if you have continued and passed test… continue………….

Step 1 : GET Kaggle API token

go to your account section and below you’ll see ..

generate new api with create options

A kaggle.json file will be downloaded further on.

Step2 :Upload your json file into google drive

Step3 : create a notebook and mount google drive to access file

from google.colab import drive

drive.mount(‘/content/gdrive’)

follow the link and paste to authorize

after mounting

Step 4: Run below and provide configuration path to json file

import os
os.environ['KAGGLE_CONFIG_DIR'] = "/content/gdrive/My Drive/Kaggle"#

/content/gdrive/My Drive/Kaggle is the path where kaggle.json is present in the Google Drive

Step 5 Change work dir

#changing the working directory
%cd /content/gdrive/My Drive/Kaggle

#Check the present working directory using pwd command

Step 6 Download the kaggle dataset

From the kaggle copy api command and run the command similar to below

! kaggle datasets download -d………………….

Step 7 UnZIP and remove zip file

#unzipping the zip files and deleting the zip files

!unzip \*.zip && rm *.zip

Now you have the csv files.

--

--