https://github.com/cj-mills/cjm-kaggle-utils
Some utility functions for working with the Kaggle API.
https://github.com/cj-mills/cjm-kaggle-utils
Last synced: about 1 month ago
JSON representation
Some utility functions for working with the Kaggle API.
- Host: GitHub
- URL: https://github.com/cj-mills/cjm-kaggle-utils
- Owner: cj-mills
- License: mit
- Created: 2023-02-02T20:53:42.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-02-08T18:26:38.000Z (over 2 years ago)
- Last Synced: 2025-09-08T17:01:04.347Z (about 1 month ago)
- Language: Jupyter Notebook
- Homepage: https://cj-mills.github.io/cjm-kaggle-utils/
- Size: 46.9 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
cjm-kaggle-utils
================## Install
``` sh
pip install cjm_kaggle_utils
```## How to use
### save_kaggle_creds
``` python
from cjm_kaggle_utils.core import save_kaggle_creds
`````` python
username = "name"
key = "12345"
save_kaggle_creds(username, key, overwrite=False)
```Credentials already present. Set `overwrite=True` to replace them.
### dl_kaggle
``` python
from cjm_kaggle_utils.core import dl_kaggle
from pathlib import Path
`````` python
# Get the path to the directory where datasets are stored
dataset_dir = Path("./Datasets/")
dataset_dir.mkdir(parents=True, exist_ok=True)
print(f"Dataset Directory: {dataset_dir}")# Create the path to the data directory
archive_dir = dataset_dir/'../Archive'
archive_dir.mkdir(parents=True, exist_ok=True)
print(f"Archive Directory: {archive_dir}")
```Dataset Directory: Datasets
Archive Directory: Datasets/../Archive``` python
# Set the name of the dataset
dataset_name = 'style-image-samples'# Construct the Kaggle dataset name by combining the username and dataset name
kaggle_dataset = f'innominate817/{dataset_name}'
`````` python
# Create the path to the zip file that contains the dataset
archive_path = Path(f'{archive_dir}/{dataset_name}.zip')
print(f"Archive Path: {archive_path}")# Create the path to the directory where the dataset will be extracted
dataset_path = Path(f'{dataset_dir}/{dataset_name}')
print(f"Dataset Path: {dataset_path}")
```Archive Path: Datasets/../Archive/style-image-samples.zip
Dataset Path: Datasets/style-image-samples``` python
dl_kaggle(kaggle_dataset, archive_path, dataset_path)
```Downloading style-image-samples.zip to Datasets/../Archive
100%|██████████████████████████████████████████████████████████████████████████████████████████████| 16.2M/16.2M [00:00<00:00, 44.0MB/s]
``` python
!ls {dataset_path}
```images