jupyter-io


Namejupyter-io JSON
Version 2.0.1 PyPI version JSON
download
home_pageNone
SummarySaving and loading files directly into Jupyter notebooks
upload_time2024-12-28 14:39:12
maintainerNone
docs_urlNone
authorNone
requires_python<3.14,>=3.9
licenseMIT License Copyright (c) 2020-2024 Akio Taniguchi Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords io jupyter python
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # jupyter-io

[![Release](https://img.shields.io/pypi/v/jupyter-io?label=Release&color=cornflowerblue&style=flat-square)](https://pypi.org/project/jupyter-io/)
[![Python](https://img.shields.io/pypi/pyversions/jupyter-io?label=Python&color=cornflowerblue&style=flat-square)](https://pypi.org/project/jupyter-io/)
[![Downloads](https://img.shields.io/pypi/dm/jupyter-io?label=Downloads&color=cornflowerblue&style=flat-square)](https://pepy.tech/project/jupyter-io)
[![DOI](https://img.shields.io/badge/DOI-10.5281/zenodo.14379974-cornflowerblue?style=flat-square)](https://doi.org/10.5281/zenodo.14379974)
[![Tests](https://img.shields.io/github/actions/workflow/status/astropenguin/jupyter-io/tests.yaml?label=Tests&style=flat-square)](https://github.com/astropenguin/jupyter-io/actions)

Saving and loading files directly into Jupyter notebooks

## Installation

```shell
pip install jupyter-io
```

## File saving

jupyter-io provides the `in_notebook` function to directly save (i.e. embed) files to Jupyter notebooks.
Suppose you create a Matplotlib figure want to save it as a PDF file.
The following code will save the PDF file to your local environment:
```python
import matplotlib.pyplot as plt

plt.plot([1, 2, 3])
plt.savefig("figure.pdf")
```
This should work in many cases, however, in a virtual environment like [Google Colaboratory](https://colab.research.google.com/), you will not be able to get the file once the Jupyter server is stopped.
By wrapping the file path by `in_notebook`, the PDF file will be directly saved to the Jupyter notebook and you will get a download link instead:
```python
import matplotlib.pyplot as plt
from jupyter_io import in_notebook

plt.plot([1, 2, 3])
plt.savefig(in_notebook("figure.pdf"))
```
The download link works when the Jupyter server is stopped, and even when it does not exist.
This makes Jupyter notebooks more portable, for example, to share the output data other than images together with them.

### More examples

To save a pandas series to a notebook:

```python
import pandas as pd
from jupyter_io import in_notebook

ser = pd.Series([1, 2, 3])
ser.to_csv(in_notebook("series.csv"))
```

To save a general text to a notebook:

```python
from jupyter_io import in_notebook

with open(in_notebook("output.txt"), "w") as f:
    f.write("1, 2, 3\n")
```

## File loading

The file loading feature has not been implemented yet.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "jupyter-io",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<3.14,>=3.9",
    "maintainer_email": null,
    "keywords": "io, jupyter, python",
    "author": null,
    "author_email": "Akio Taniguchi <taniguchi.akio@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/35/13/b7bc75c9afffa5451039c8cf145f9a2d0779fa73eedeac3f9995392acb0e/jupyter_io-2.0.1.tar.gz",
    "platform": null,
    "description": "# jupyter-io\n\n[![Release](https://img.shields.io/pypi/v/jupyter-io?label=Release&color=cornflowerblue&style=flat-square)](https://pypi.org/project/jupyter-io/)\n[![Python](https://img.shields.io/pypi/pyversions/jupyter-io?label=Python&color=cornflowerblue&style=flat-square)](https://pypi.org/project/jupyter-io/)\n[![Downloads](https://img.shields.io/pypi/dm/jupyter-io?label=Downloads&color=cornflowerblue&style=flat-square)](https://pepy.tech/project/jupyter-io)\n[![DOI](https://img.shields.io/badge/DOI-10.5281/zenodo.14379974-cornflowerblue?style=flat-square)](https://doi.org/10.5281/zenodo.14379974)\n[![Tests](https://img.shields.io/github/actions/workflow/status/astropenguin/jupyter-io/tests.yaml?label=Tests&style=flat-square)](https://github.com/astropenguin/jupyter-io/actions)\n\nSaving and loading files directly into Jupyter notebooks\n\n## Installation\n\n```shell\npip install jupyter-io\n```\n\n## File saving\n\njupyter-io provides the `in_notebook` function to directly save (i.e. embed) files to Jupyter notebooks.\nSuppose you create a Matplotlib figure want to save it as a PDF file.\nThe following code will save the PDF file to your local environment:\n```python\nimport matplotlib.pyplot as plt\n\nplt.plot([1, 2, 3])\nplt.savefig(\"figure.pdf\")\n```\nThis should work in many cases, however, in a virtual environment like [Google Colaboratory](https://colab.research.google.com/), you will not be able to get the file once the Jupyter server is stopped.\nBy wrapping the file path by `in_notebook`, the PDF file will be directly saved to the Jupyter notebook and you will get a download link instead:\n```python\nimport matplotlib.pyplot as plt\nfrom jupyter_io import in_notebook\n\nplt.plot([1, 2, 3])\nplt.savefig(in_notebook(\"figure.pdf\"))\n```\nThe download link works when the Jupyter server is stopped, and even when it does not exist.\nThis makes Jupyter notebooks more portable, for example, to share the output data other than images together with them.\n\n### More examples\n\nTo save a pandas series to a notebook:\n\n```python\nimport pandas as pd\nfrom jupyter_io import in_notebook\n\nser = pd.Series([1, 2, 3])\nser.to_csv(in_notebook(\"series.csv\"))\n```\n\nTo save a general text to a notebook:\n\n```python\nfrom jupyter_io import in_notebook\n\nwith open(in_notebook(\"output.txt\"), \"w\") as f:\n    f.write(\"1, 2, 3\\n\")\n```\n\n## File loading\n\nThe file loading feature has not been implemented yet.\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2020-2024 Akio Taniguchi  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
    "summary": "Saving and loading files directly into Jupyter notebooks",
    "version": "2.0.1",
    "project_urls": {
        "homepage": "https://astropenguin.github.io/jupyter-io/v2.0.1",
        "repository": "https://github.com/astropenguin/jupyter-io"
    },
    "split_keywords": [
        "io",
        " jupyter",
        " python"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "b4b40ec6640f23781ca9f993fb308c126dab68e7acf9f3372c4a865dd6a65dda",
                "md5": "e9f0c95eeade417099f1bc90604f2928",
                "sha256": "c03b1f68ea696058aec19dd5a657d25f028957ac25743b3a732828a6b3555a1c"
            },
            "downloads": -1,
            "filename": "jupyter_io-2.0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e9f0c95eeade417099f1bc90604f2928",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<3.14,>=3.9",
            "size": 6536,
            "upload_time": "2024-12-28T14:39:10",
            "upload_time_iso_8601": "2024-12-28T14:39:10.204135Z",
            "url": "https://files.pythonhosted.org/packages/b4/b4/0ec6640f23781ca9f993fb308c126dab68e7acf9f3372c4a865dd6a65dda/jupyter_io-2.0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "3513b7bc75c9afffa5451039c8cf145f9a2d0779fa73eedeac3f9995392acb0e",
                "md5": "a2af1a0443385729914f446a4f18fd3f",
                "sha256": "f1628da77450740fad7aa7a1ba5c46f66a93c4cc0e5f24656f43f784e93fedb3"
            },
            "downloads": -1,
            "filename": "jupyter_io-2.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "a2af1a0443385729914f446a4f18fd3f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<3.14,>=3.9",
            "size": 83255,
            "upload_time": "2024-12-28T14:39:12",
            "upload_time_iso_8601": "2024-12-28T14:39:12.394609Z",
            "url": "https://files.pythonhosted.org/packages/35/13/b7bc75c9afffa5451039c8cf145f9a2d0779fa73eedeac3f9995392acb0e/jupyter_io-2.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-28 14:39:12",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "astropenguin",
    "github_project": "jupyter-io",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "jupyter-io"
}
        
Elapsed time: 0.79672s