How to download a Kaggle Competition Dataset on Kaggle Notebook?

Niranjainjain
3 min readJul 4, 2021

--

https://digital.hbs.edu/platform-digit/wp-content/uploads/sites/2/2017/03/Screen-Shot-2017-03-20-at-11.01.42-AM.png

I have recently participated in SIIM-FISABIO-RSNA COVID-19 Detection competition. I was struggling with how to get the datasets. Thanks to the Kaggle API installation and documentation as it helped me get through this problem.

Here is the link for even more advance features you might want to explore:
https://github.com/Kaggle/kaggle-api

However, for the one who is participating for the first time in a kaggle competition, (like me), might take a little time understanding all those things on repository as not many might be used to it. No worries here is a easy demonstration showing how one can do it!

Step 1: Go to your Kaggle profile and click on the account button. Here is an image to show how it might look like once you are there:

You can notice at the bottom of the image the blue-highlighted Account button.

Step 2: Scroll down through the account section till you reach API section. Once you are at API section, you fill notice a “Create New API Token” button. Click on that and you will see a “kaggle.json” downloading. It won’t take much time, probably a second. Here is a view at the API section:

The “Create New API Token” button can be seen at the bottom left corner of the image.

Step 3: Open the Kaggle notebook where you will be working and upload the “kaggle.json” file to any directory. For simplicity, just follow the images below:

At top right corner you will find this section, click on Add data
After the click, this window shows up. Click on the upload button on the top right corner.
Give the name to the directory where you will be uploading the file and upload the “kaggle.json” from the file directory. Once done, click on create.
We can see that kaggle.json is here!

Step 4: Let’s move this “kaggle.json” file to root folder as it’s required for it to be in that location else the download won’t be possible. We write this one line of code to do the job:

!cp ../input/kagglejson/kaggle.json /root/.kaggle

NOTE: Don’t forget to change the folders name if you have chosen different name

Step 5: Install kaggle library and import and run the following kaggle command in new cell to see if its working or not:

So, here we learned how can one simply download kaggle competition dataset on kaggle notebook.

If you liked it, do give an upvote! Checkout my GitHub for simple ML and DL projects with explaination!

https://www.github.com/niranjainjain022

Here is my LinkedIn handle do connect!

https://www.linkedin.com/in/niranjan-jain-548711172/

--

--