Home  >  Article  >  Backend Development  >  How to import data from Kaggle without downloading it?

How to import data from Kaggle without downloading it?

WBOY
WBOYforward
2024-02-05 23:42:111139browse

如何在不下载数据的情况下从 Kaggle 导入数据?

Question content

I want to import data from kaggle into my notebook without having to download it (so if I share my .ipynb, You just have to run the code and it will download it from the internet) but I don't know if it is possible and which link to copy. This 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 shows: parsererror: Error while marking data. c Error: Line 9 should have 1 field but saw 2


Correct answer


First approach

You can go to the dataset page and click New Notebook in the upper right corner

The second method

Open any notebook and click "Add Data" in the right menu

The third method

Not recommended because everyone who opens ipynb must first upload their own token.

When using colab, first download your kaggke json key and perform the following steps

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

In our example, [user/data-name] is kukuroo3/body-performance-data

The above is the detailed content of How to import data from Kaggle without downloading it?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:stackoverflow.com. If there is any infringement, please contact admin@php.cn delete