2

My question is a continuation of: documentation for Kaggle API *within* python?.

So, I download a dataset with the Kaggle API:

api.dataset_download_files('berkeleyearth/climate-change-earth-surface-temperature-data',
                           path='datasets/kaggle', unzip=True)

Is there a way to fetch the name of the downloaded csv files? Or do I have to make sure I download (and unzip) the files in a dedicated folder that I should then browse?

compuphys
  • 1,289
  • 12
  • 28
mrgou
  • 1,576
  • 2
  • 21
  • 45
  • Some unofficial documentation here: [https://technowhisp.com/kaggle-api-python-documentation/](https://technowhisp.com/kaggle-api-python-documentation/) – compuphys Apr 15 '20 at 07:35
  • 1
    Yes, that's what I wanted! :) ```python file_list = api.dataset_list_files('berkeleyearth/climate-change-earth-surface-temperature-data').files ``` – mrgou Apr 15 '20 at 07:41

2 Answers2

1

See the documentation here: https://technowhisp.com/kaggle-api-python-documentation/

5.2 Listing dataset files

api.dataset_list_files('avenn98/world-of-warcraft-demographics').files

Community
  • 1
  • 1
compuphys
  • 1,289
  • 12
  • 28
0
pip install kaggle 

then authenticate

Authenticating With API Server

 from kaggle.api.kaggle_api_extended import KaggleApi
 api = KaggleApi()
 api.authenticate()
Downloading Datasets

and download

# Download all files of a dataset
# Signature: dataset_download_files(dataset, path=None, force=False, quiet=True, unzip=False)
api.dataset_download_files('avenn98/world-of-warcraft-demographics')

# downoad single file
#Signature: dataset_download_file(dataset, file_name, path=None, force=False, quiet=True)
api.dataset_download_file('avenn98/world-of-warcraft-demographics','WoW Demographics.csv')
kiriloff
  • 25,609
  • 37
  • 148
  • 229