Skip to main content

Jupyter Notebook Splitter

Project description

Jupyter Notebook Splitter

This 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.

Installation

Although the Notebook Splitter is only a single file it can be installed via pip

pip install notebook-splitter

Usage

Overview

TL;DR: See notebook-splitter --help.

  1. Add 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

    {
        "exercise": "task"
    }
    // another cell
    {
        "exercise": "solution"
    }
    
  2. Use --keep and --remove flags of the Notebook Splitter to keep and remove cells with according tags; export it to the respective Notebook:

    notebook-splitter input.ipynb --keep task --remove solution   -o tasks.ipynb
    notebook-splitter input.ipynb --keep solution --remove task   -o solutions.ipynb
    notebook-splitter input.ipynb --remove task --remove solution -o slides.ipynb
    

Examples in Action

See the examples directory in this repository.

Options

  • Repeated Parameters: --keep and --remove parameters on the command line of the script can be given multiple times: --keep task --keep onlytask --remove solution
  • 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)
  • 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)
  • 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.

Limitations

The 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!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

notebook_splitter-1.5.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

notebook_splitter-1.5-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file notebook_splitter-1.5.tar.gz.

File metadata

  • Download URL: notebook_splitter-1.5.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.19.1 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.4

File hashes

Hashes for notebook_splitter-1.5.tar.gz
Algorithm Hash digest
SHA256 03e7d3c119c684d859d5d2d6b06cf1f7b2ab35f7677d2461bf67847bdab96ec0
MD5 d5bbb5af1b0e2ac929187b2698abbe2e
BLAKE2b-256 00ae9b790b794d89e2d0c09f18385b1a2f01b526dd9461d448ef4efc84a1681b

See more details on using hashes here.

File details

Details for the file notebook_splitter-1.5-py3-none-any.whl.

File metadata

  • Download URL: notebook_splitter-1.5-py3-none-any.whl
  • Upload date:
  • Size: 4.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.19.1 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.4

File hashes

Hashes for notebook_splitter-1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 2d3e759ccbb007c6e413a08d8d99a3097efbb7c676ceb68051e1859ba8bbddfc
MD5 5b73e278a5206138bf05c4fd1bd0d7ad
BLAKE2b-256 707d19189674baa54a78da1def26f258f579c014560b70c2c35d7f3bc4f914df

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page