cjm-kaggle-utils


Namecjm-kaggle-utils JSON
Version 0.0.3 PyPI version JSON
download
home_pagehttps://github.com/cj-mills/cjm-kaggle-utils
SummarySome utility functions for working with the Kaggle API.
upload_time2023-02-03 00:35:13
maintainer
docs_urlNone
authorcj-mills
requires_python>=3.7
licenseApache Software License 2.0
keywords nbdev jupyter notebook python
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            cjm-kaggle-utils
================

<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->

## 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%|██████████████████████████████████████| 27.5M/27.5M [00:00<00:00, 56.0MB/s]

``` python
!ls {dataset_path}
```

    images

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/cj-mills/cjm-kaggle-utils",
    "name": "cjm-kaggle-utils",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "nbdev jupyter notebook python",
    "author": "cj-mills",
    "author_email": "millscj.mills2@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/1a/c2/6eace78c71b3e3a24aff6052d45283cb40fb0f695f1e11c6cfe5647c503f/cjm-kaggle-utils-0.0.3.tar.gz",
    "platform": null,
    "description": "cjm-kaggle-utils\n================\n\n<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->\n\n## Install\n\n``` sh\npip install cjm_kaggle_utils\n```\n\n## How to use\n\n### save_kaggle_creds\n\n``` python\nfrom cjm_kaggle_utils.core import save_kaggle_creds\n```\n\n``` python\nusername = \"name\"\nkey = \"12345\"\nsave_kaggle_creds(username, key, overwrite=False)\n```\n\n    Credentials already present. Set `overwrite=True` to replace them.\n\n### dl_kaggle\n\n``` python\nfrom cjm_kaggle_utils.core import dl_kaggle\nfrom pathlib import Path\n```\n\n``` python\n# Get the path to the directory where datasets are stored\ndataset_dir = Path(\"./Datasets/\")\ndataset_dir.mkdir(parents=True, exist_ok=True)\nprint(f\"Dataset Directory: {dataset_dir}\")\n\n# Create the path to the data directory\narchive_dir = dataset_dir/'../Archive'\narchive_dir.mkdir(parents=True, exist_ok=True)\nprint(f\"Archive Directory: {archive_dir}\")\n```\n\n    Dataset Directory: Datasets\n    Archive Directory: Datasets/../Archive\n\n``` python\n# Set the name of the dataset\ndataset_name = 'style-image-samples'\n\n# Construct the Kaggle dataset name by combining the username and dataset name\nkaggle_dataset = f'innominate817/{dataset_name}'\n```\n\n``` python\n# Create the path to the zip file that contains the dataset\narchive_path = Path(f'{archive_dir}/{dataset_name}.zip')\nprint(f\"Archive Path: {archive_path}\")\n\n# Create the path to the directory where the dataset will be extracted\ndataset_path = Path(f'{dataset_dir}/{dataset_name}')\nprint(f\"Dataset Path: {dataset_path}\")\n```\n\n    Archive Path: Datasets/../Archive/style-image-samples.zip\n    Dataset Path: Datasets/style-image-samples\n\n``` python\ndl_kaggle(kaggle_dataset, archive_path, dataset_path)\n```\n\n    Downloading style-image-samples.zip to Datasets/../Archive\n\n    100%|\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588| 27.5M/27.5M [00:00<00:00, 56.0MB/s]\n\n``` python\n!ls {dataset_path}\n```\n\n    images\n",
    "bugtrack_url": null,
    "license": "Apache Software License 2.0",
    "summary": "Some utility functions for working with the Kaggle API.",
    "version": "0.0.3",
    "split_keywords": [
        "nbdev",
        "jupyter",
        "notebook",
        "python"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1c81425d40c42a4924f295416926e680358d8c5a11605db51ec48a71be654966",
                "md5": "a198f26165c10a7c46ee1430c2d4c5a3",
                "sha256": "26f09b86b75172c53922a28743d87a3338b7e9e3e1e92f01cd7571119dc056e1"
            },
            "downloads": -1,
            "filename": "cjm_kaggle_utils-0.0.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a198f26165c10a7c46ee1430c2d4c5a3",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 5195,
            "upload_time": "2023-02-03T00:35:11",
            "upload_time_iso_8601": "2023-02-03T00:35:11.387417Z",
            "url": "https://files.pythonhosted.org/packages/1c/81/425d40c42a4924f295416926e680358d8c5a11605db51ec48a71be654966/cjm_kaggle_utils-0.0.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1ac26eace78c71b3e3a24aff6052d45283cb40fb0f695f1e11c6cfe5647c503f",
                "md5": "3321d3ba9999631a1fd93ba0bbe5429d",
                "sha256": "bc1f31a468cbf579471e13845b5daecc9bf4a66e5f3515cb1a99b144ab840f12"
            },
            "downloads": -1,
            "filename": "cjm-kaggle-utils-0.0.3.tar.gz",
            "has_sig": false,
            "md5_digest": "3321d3ba9999631a1fd93ba0bbe5429d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 5601,
            "upload_time": "2023-02-03T00:35:13",
            "upload_time_iso_8601": "2023-02-03T00:35:13.437598Z",
            "url": "https://files.pythonhosted.org/packages/1a/c2/6eace78c71b3e3a24aff6052d45283cb40fb0f695f1e11c6cfe5647c503f/cjm-kaggle-utils-0.0.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-02-03 00:35:13",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "cj-mills",
    "github_project": "cjm-kaggle-utils",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "cjm-kaggle-utils"
}
        
Elapsed time: 0.04678s