Created
November 14, 2014 22:18
-
-
Save wx13/3e4cf47e3572b5e86321 to your computer and use it in GitHub Desktop.
Python script to remove outputs from an ipython notebook (without requiring ipython to be installed)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
from sys import argv | |
def strip_output(nb): | |
for ws in nb['worksheets']: | |
for cell in ws['cells']: | |
if 'outputs' in cell: | |
cell['outputs'] = [] | |
if __name__ == '__main__': | |
with open(argv[1],'r') as f: | |
nb = json.load(f) | |
strip_output(nb) | |
print json.dumps(nb,sort_keys=True,indent=2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment