Download Data from Kaggle

In this tutorial, I will guide you to download kaggle dataset from your python notebook directly or from your command shell(to download from command shell remove the exclamation mark(!) from start). Here are the necessary steps to follow:

  1.  Sign in to your kaggle account and enter into the competition by accepting its rules for which you need data to be downloaded.
  2. Firstly, install kaggle cli using pip by writing following command into python notebook:
    !pip install kaggle-cli
  3. If you get any error while executing the previous step try the following command instead:
    !pip install kaggle-cli –upgrade
  4. Then configure your kaggle account with your username, password and competition name from which data to be downloaded. Your username and password should be inside inverted comma. The command is as follows:
    !kg config -u ‘username’ -p ‘password’ -c competitonName
    competition name for downloading dataset can be extracted from competition’s URL e.g if competition’s URL is https://www.kaggle.com/c/imagenet-object-detection-challenge then competition name would be imagenet-object-detection-challenge.
  5. And finally, write following command to download data:
    !kg download
  6. Then you can extract dataset into the particular folder by using the following command:
    !unzip –q filename.zip -d folderName
  7. You can also download particular data file from kaggle using following command:
    !kg download -u ‘username’ -p ‘password’ -c competitonName -f fileName

Enjoy!!!

Leave a Reply