Function Repository Resource:

KaggleDownload

Source Notebook

Download a Kaggle dataset

Contributed by: Arnoud Buzing

ResourceFunction["KaggleDownload"][id]

downloads Kaggle datasets associated with id to a local cache directory.

Details

KaggleDownload returns a list of filenames that can subsequently be imported with Import.
The dataset id is typically obtained by first searching for datasets with KaggleSearch.
KaggleDownload requires a Kaggle account, and you must create an API token on the Kaggle Settings web page. The API token can then be downloaded to your system as a "kaggle.json" file and must be placed in your "~/.kaggle" directory (or on Windows: %HOMEPATH%/kaggle.json)

Examples

Basic Examples

Search for datasets:

In[1]:=
ds = ResourceFunction["KaggleSearch"]["biology"]
Out[1]=

Select a dataset and retrieve the path:

In[2]:=
path = FileNameTake[ds[1, "url"], -2]
Out[2]=

Download and return the files associated with the given dataset:

In[3]:=
files = ResourceFunction["KaggleDownload"][path]
Out[3]=

Import the training "CSV" file as a Tabular object:

In[4]:=
Import[Part[files, 3], "Tabular"]
Out[4]=

Import the test "CSV" file as a Tabular object:

In[5]:=
Import[Part[files, 2], "Tabular"]
Out[5]=

Publisher

Arnoud Buzing

Version History

  • 1.0.0 – 17 January 2025

License Information