-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdatasetDownloader.py
More file actions
39 lines (26 loc) · 1.09 KB
/
datasetDownloader.py
File metadata and controls
39 lines (26 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File needed for the dowload the dataset (moltean/fruits: https://www.kaggle.com/datasets/moltean/fruits) from Kaggle
import os
import zipfile
from kaggle.api.kaggle_api_extended import KaggleApi
def checkFolder(path):
""" Return True if a folder do not exist or if is empty """
if os.path.exists(path):
return len( os.listdir(path)) == 0
else:
return True
if __name__ == "__main__":
os.environ['KAGGLE_USERNAME'] = 'matteocalvanico'
os.environ['KAGGLE_KEY'] = '2c941be0e8b7029e2b4aa07d87c40478'
api = KaggleApi()
api.authenticate()
# If Kaggle doesn't find the environment variables go to: C:\Users\<name>\.kaggle
# and create a json file named kaggle.json
# and put this inside: {"username":"matteocalvanico","key":"2c941be0e8b7029e2b4aa07d87c40478"}
dataset = 'moltean/fruits'
path = 'dataset'
if checkFolder("./dataset"):
print("Starting download...")
api.dataset_download_files(dataset, path, unzip=True)
print("Download ended")
else:
print("Dataset already installed, download blocked")