{"id":14977345,"url":"https://github.com/andih/notebook-splitter","last_synced_at":"2025-10-28T03:31:18.698Z","repository":{"id":57446814,"uuid":"174519238","full_name":"AndiH/notebook-splitter","owner":"AndiH","description":"Split Jupyter Notebooks into Sub-Notebooks by Cell Metadata","archived":false,"fork":false,"pushed_at":"2019-11-08T08:07:40.000Z","size":11,"stargazers_count":3,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-04-23T22:55:15.331Z","etag":null,"topics":["classroom","classroom-tools","json","jupyter","jupyter-notebook","python-script"],"latest_commit_sha":null,"homepage":null,"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/AndiH.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":"2019-03-08T10:42:52.000Z","updated_at":"2019-11-08T08:07:42.000Z","dependencies_parsed_at":"2022-09-02T22:20:09.769Z","dependency_job_id":null,"html_url":"https://github.com/AndiH/notebook-splitter","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AndiH%2Fnotebook-splitter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AndiH%2Fnotebook-splitter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AndiH%2Fnotebook-splitter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AndiH%2Fnotebook-splitter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AndiH","download_url":"https://codeload.github.com/AndiH/notebook-splitter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238590593,"owners_count":19497351,"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":["classroom","classroom-tools","json","jupyter","jupyter-notebook","python-script"],"created_at":"2024-09-24T13:55:29.296Z","updated_at":"2025-10-28T03:31:08.666Z","avatar_url":"https://github.com/AndiH.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Jupyter Notebook Splitter\n\nThis tool splits a Jupyter Notebook into Sub-Notebooks depending on cell metadata. It converts a *Master* Notebook into a *Teacher* Notebook and a *Student* Notebook; or into a *Slides* Notebook, a *Tasks* Notebook, and a *Solutions* Notebook.\n\n## Installation\n\nAlthough the Notebook Splitter is only a single file it can be installed via `pip`\n\n```bash\npip install notebook-splitter\n```\n\n## Usage\n\n### Overview\n\n**TL;DR: See `notebook-splitter --help`.**\n\n1. Add [cell metadata](https://ipython.org/ipython-doc/3/notebook/nbformat.html#cell-metadata) to your Jupyter Notebook: Add an `exercise` key (default, can be changed) to the metadata (JSON); give it values (*tags*) on which to create Sub-Notebooks\n\n    ```json\n    {\n        \"exercise\": \"task\"\n    }\n    // another cell\n    {\n        \"exercise\": \"solution\"\n    }\n    ```\n\n2. Use `--keep` and `--remove` flags of the Notebook Splitter to keep and remove cells with according *tags*; export it to the respective Notebook:\n\n    ```bash\n    notebook-splitter input.ipynb --keep task --remove solution   -o tasks.ipynb\n    notebook-splitter input.ipynb --keep solution --remove task   -o solutions.ipynb\n    notebook-splitter input.ipynb --remove task --remove solution -o slides.ipynb\n    ```\n\n### Examples in Action\n\nSee the `examples` directory in this repository.\n\n### Options\n\n* **Repeated Parameters**: `--keep` and `--remove` parameters on the command line of the script can be given multiple times: `--keep task --keep onlytask --remove solution`\n* **Remove *All***: As a special parameter value, `--remove all` will remove *all* cells except those for which a `--keep` value is specified (*`--keep all`* is the default)\n* **Stdin/Stdout**: If no output file is given with `-o`/`--output`, the resulting Notebook will be printed to `stdout`; if no input file as a parameter is given, the input Notebook will be read from `stdin` (good for Linux-like daisy-chaining of tools)\n* **Change *Basekey***: In the above example, the cell meta data key of discrimination is `exercise` which is the default. With `--basekey`, this can be changed.\n\n### Limitations\n\nThe values to the `--keep` and `--remove` parameters create sets of values to keep and remove. One could implement this tool probably quite cleverly with set operations (with the added complication of the `--remove all` ). If you can, feel free to file a merge request!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandih%2Fnotebook-splitter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandih%2Fnotebook-splitter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandih%2Fnotebook-splitter/lists"}