How can i import data from kaggle while not downloading it?

Question:

I want to import data from kaggle to my Notebook while not having to download it (So if i share my .ipynb u only need to run the code and it will download it from the internet), but i can’t figure out if it is even possible and which link to copy. Here is the kaggle website:

https://www.kaggle.com/datasets/kukuroo3/body-performance-data/data?select=bodyPerformance.csv

data = pd.read_csv('link here')

I tried copying the download button link, but it doesn’t work and says: ParserError: Error tokenizing data. C error: Expected 1 fields in line 9, saw 2

Answers:

1st method

you can head into the dataset page and click on new notebook at the top right corner
enter image description here

2nd method

open any notebook and click on add data at the right menue

enter image description here

3rd method

not recommended, since each person that opens the ipynb will have to upload their own token first.

when using colab first download your kaggke json key and do the following steps

  • create a kaggle key, you can go into your settings then head into the account tab and you can find a create new token button in the api section, click on it to download your token.
    enter image description here
  • install the kaggle library
! pip install  kaggle
  • upload your kaggle key or you can put the following code to upload the key
from google.colab import files
files.upload()
  • now you can download your dataset using the following code
!kaggle datasets download -d [user/data-name]

in our example here [user/data-name] is kukuroo3/body-performance-data

enter image description here

Answered By: hafedh
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.