|
import opendatasets as od |
|
import os |
|
import json |
|
from dotenv import load_dotenv |
|
|
|
|
|
load_dotenv() |
|
|
|
DATASET_URL = "https://www.kaggle.com/datasets/atharvaingle/crop-recommendation-dataset" |
|
|
|
def create_kaggle_json_file(): |
|
|
|
username = os.getenv('username') |
|
key = os.getenv('key') |
|
|
|
kaggle_credentials = { |
|
"username": username, |
|
"key": key |
|
} |
|
|
|
|
|
kaggle_file_path = os.path.join(os.getcwd(), 'kaggle.json') |
|
|
|
|
|
with open(kaggle_file_path, 'w') as file: |
|
json.dump(kaggle_credentials, file) |
|
|
|
def remove_kaggle_json_file(): |
|
|
|
kaggle_file_path = os.path.join(os.getcwd(), 'kaggle.json') |
|
|
|
|
|
os.remove(kaggle_file_path) |
|
|
|
create_kaggle_json_file() |
|
|
|
od.download(DATASET_URL) |
|
|
|
|
|
remove_kaggle_json_file() |