NBSTRIPOUT(1)

NAME
nbstripout - strip output from Jupyter and IPython notebooks

DESCRIPTION
usage: nbstripout [-h] [--dry-run | --install | --uninstall | --is-installed |

    --status | --version] [--verify] [--keep-count] [--keep-output] [--keep-id] [--extra-keys EXTRA_KEYS] [--keep-metadata-keys KEEP_METADATA_KEYS] [--drop-empty-cells] [--drop-tagged-cells DROP_TAGGED_CELLS] [--strip-init-cells] [--attributes FILEPATH] [--global | --system | --python PATH] [--force] [--max-size SIZE] [--mode {jupyter,zeppelin}] [--textconv] [files ...]

  positional arguments:

files
    Files to strip output from

  options:

-h, --help
    show this help message and exit

--dry-run
    Print which notebooks would have been stripped

--install
    Install nbstripout in the current repository (set up the git filter and attributes)

--uninstall
    Uninstall nbstripout from the current repository (remove the git filter and attributes)

--is-installed
    Check if nbstripout is installed in current repository

--status
    Print status of nbstripout installation in current repository and configuration summary if installed

--version
    Print version

--verify
    Return a non-zero exit code if any files were changed, Implies --dry-run

--keep-count
    Do not strip the execution count/prompt number

--keep-output
    Do not strip output

--keep-id
    Keep the randomly generated cell ids, which will be different after each execution.

--extra-keys EXTRA_KEYS
    Space separated list of extra keys to strip from metadata, e.g. metadata.foo cell.metadata.bar

--keep-metadata-keys KEEP_METADATA_KEYS
    Space separated list of metadata keys to keep, e.g. metadata.foo cell.metadata.bar

--drop-empty-cells
    Remove cells where `source` is empty or contains only whitepace

--drop-tagged-cells DROP_TAGGED_CELLS
    Space separated list of cell-tags that remove an entire cell

--strip-init-cells
    Remove cells with `init_cell: true` metadata (default: False)

--attributes FILEPATH
    Attributes file to add the filter to (in combination with --install/--uninstall), defaults to .git/info/attributes

--global
    Use global git config (default is local config)

--system
    Use system git config (default is local config)

--python PATH
    Path to python executable to use when --install'ing (default is deduced from `sys.executable`)

--force, -f
    Strip output also from files with non ipynb extension

--max-size SIZE
    Keep outputs smaller than SIZE

--mode, -m {jupyter,zeppelin}
    Specify mode between [jupyter (default) | zeppelin] (to be used in combination with -f)

--textconv, -t
    Prints stripped files to STDOUT

Strip output from Jupyter and IPython notebooks ===============================================

Opens a notebook, strips its output, and writes the outputless version to the original file.

Useful mainly as a git filter or pre-commit hook for users who don't want to track output in VCS.

This does mostly the same thing as the `Clear All Output` command in the notebook UI.

Usage =====

Strip output from IPython / Jupyter / Zeppelin notebook (modifies the file in-place): ::

    nbstripout <file.ipynb> nbstripout <file.zpln>

By default, nbstripout will only modify files ending in '.ipynb' or '.zpln', to process other files us the '-f' flag to force the application.

    nbstripout -f <file.ipynb.bak>

  For using Zeppelin mode while processing files with other extensions use:

    nbstripout -m zeppelin -f <file.ext>

Use as part of a shell pipeline: ::

    cat FILE.ipynb | nbstripout > OUT.ipynb cat FILE.zpln | nbstripout -m zeppelin > OUT.zpln

Set up the git filter and attributes as described in the manual installation instructions below: ::

    nbstripout --install

Set up the git filter using ``.gitattributes`` ::

    nbstripout --install --attributes .gitattributes

Set up the git filter in your global ``~/.gitconfig`` ::

    nbstripout --install --global

Set up the git filter in your system-wide ``$(prefix)/etc/gitconfig`` (most installations will require you to ``sudo``) ::

    [sudo] nbstripout --install --system

Remove the git filter and attributes: ::

    nbstripout --uninstall

Remove the git filter from your global ``~/.gitconfig`` and attributes ::

    nbstripout --uninstall --global

Remove the git filter from your system-wide ``$(prefix)/etc/gitconfig`` and attributes ::

    nbstripout --uninstall --system

Remove the git filter and attributes from ``.gitattributes``: ::

    nbstripout --uninstall --attributes .gitattributes

Check if ``nbstripout`` is installed in the current repository (exits with code 0 if installed, 1 otherwise): ::

    nbstripout --is-installed

Print status of ``nbstripout`` installation in the current repository and configuration summary of filter and attributes if installed (exits with code 0 if installed, 1 otherwise): ::

    nbstripout --status

Do a dry run and only list which files would have been stripped: ::

    nbstripout --dry-run FILE.ipynb [FILE2.ipynb ...]

Print the version: ::

    nbstripout --version

Show this help page: ::

    nbstripout --help

Manual filter installation ==========================

Set up a git filter using nbstripout as follows: ::

    git config filter.nbstripout.clean '/path/to/nbstripout' git config filter.nbstripout.smudge cat

Create a file ``.gitattributes`` or ``.git/info/attributes`` with: ::

    *.ipynb filter=nbstripout

Apply the filter for git diff of ``*.ipynb`` files: ::

    git config diff.ipynb.textconv '/path/to/nbstripout -t'

In file ``.gitattributes`` or ``.git/info/attributes`` add: ::

    *.ipynb diff=ipynb