{"id":14977410,"url":"https://github.com/astropenguin/jupyter-io","last_synced_at":"2025-09-20T05:33:31.794Z","repository":{"id":62573398,"uuid":"236435883","full_name":"astropenguin/jupyter-io","owner":"astropenguin","description":":zap: Saving and loading files directly into Jupyter notebooks","archived":false,"fork":false,"pushed_at":"2024-12-28T14:39:25.000Z","size":2890,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-12-28T14:45:29.331Z","etag":null,"topics":["io","jupyter","python"],"latest_commit_sha":null,"homepage":"https://astropenguin.github.io/jupyter-io/v2.0.1","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/astropenguin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-01-27T07:00:34.000Z","updated_at":"2024-12-28T14:38:57.000Z","dependencies_parsed_at":"2022-11-03T18:36:53.860Z","dependency_job_id":null,"html_url":"https://github.com/astropenguin/jupyter-io","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/astropenguin%2Fjupyter-io","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/astropenguin%2Fjupyter-io/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/astropenguin%2Fjupyter-io/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/astropenguin%2Fjupyter-io/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/astropenguin","download_url":"https://codeload.github.com/astropenguin/jupyter-io/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":233634087,"owners_count":18705953,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["io","jupyter","python"],"created_at":"2024-09-24T13:55:36.539Z","updated_at":"2025-09-20T05:33:26.685Z","avatar_url":"https://github.com/astropenguin.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# jupyter-io\n\n[![Release](https://img.shields.io/pypi/v/jupyter-io?label=Release\u0026color=cornflowerblue\u0026style=flat-square)](https://pypi.org/project/jupyter-io/)\n[![Python](https://img.shields.io/pypi/pyversions/jupyter-io?label=Python\u0026color=cornflowerblue\u0026style=flat-square)](https://pypi.org/project/jupyter-io/)\n[![Downloads](https://img.shields.io/pypi/dm/jupyter-io?label=Downloads\u0026color=cornflowerblue\u0026style=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\u0026style=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","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fastropenguin%2Fjupyter-io","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fastropenguin%2Fjupyter-io","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fastropenguin%2Fjupyter-io/lists"}