Skip to main content

Strips outputs from Jupyter and IPython notebooks

Project description

https://travis-ci.org/kynan/nbstripout.svg?branch=master https://img.shields.io/pypi/dm/nbstripout.svg https://img.shields.io/pypi/v/nbstripout.svg https://img.shields.io/badge/license-MIT-blue.svg https://img.shields.io/pypi/pyversions/nbstripout.svg

nbstripout: 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.

Based on https://gist.github.com/minrk/6176788.

Usage

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

nbstripout FILE.ipynb [FILE2.ipynb ...]

Force processing of non .ipynb files:

nbstripout -f FILE.ipynb.bak

Use as part of a shell pipeline:

FILE.ipynb | nbstripout > OUT.ipynb

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

Remove the git filter and attributes:

nbstripout --uninstall

Remove the git filter and attributes from .gitattributes:

nbstripout --uninstall --attributes .gitattributes

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
git config filter.nbstripout.required true

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

*.ipynb filter=nbstripout

Mercurial usage

Mercurial does not have the equivalent of smudge filters. One can use an encode/decode hook but this has some issues. An alternative solution is to provide a set of commands that first run nbstripout, then perform these operations. This is the approach of the mmf-setup package.

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

nbstripout-0.2.6.tar.gz (7.7 kB view details)

Uploaded Source

File details

Details for the file nbstripout-0.2.6.tar.gz.

File metadata

  • Download URL: nbstripout-0.2.6.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for nbstripout-0.2.6.tar.gz
Algorithm Hash digest
SHA256 1c2990338ff9bc0d3283425c5c15dfd2c2371e41fac4cb7ee034d07ec390b1b7
MD5 09e86f12b7a211d4a4040ed939d905a7
BLAKE2b-256 445c746c418bc46e9160fda5f1318a89e4c4543e6dac68a59d05a170543e5d5c

See more details on using hashes here.

Supported by

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