Skip to content

Instantly share code, notes, and snippets.

View marscher's full-sized avatar

Martin K. Scherer marscher

  • BAM
  • Berlin, Germany
View GitHub Profile
@marscher
marscher / nbstripout
Last active August 29, 2015 14:07 — forked from minrk/nbstripout
#!/usr/bin/env python
"""strip outputs from an IPython Notebook
Opens a notebook, strips its output, and writes the outputless version to the original file.
Useful mainly as a git 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: python remove_output.py notebook.ipynb [ > without_output.ipynb ]
Modified from remove_output by Minrk
"""
import sys
import io
import os
from IPython.nbformat.current import read, write