Created
November 5, 2014 05:09
-
-
Save minrk/b95abcf698d85b5d5007 to your computer and use it in GitHub Desktop.
This file contains 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
#!/usr/bin/env python | |
""" | |
nbconcat: concatenate notebooks | |
Usage: | |
nbconcat nb1.py nb2.py [nb3.py...] > allmynbs.ipynb | |
requires IPython >= 3.0 | |
""" | |
import sys | |
import IPython | |
from IPython import nbformat | |
v = 4 | |
def nbconcat(nbfiles): | |
with open(nbfiles[0]) as f: | |
nb = nbformat.read(f, as_version=v) | |
for nbf in nbfiles[1:]: | |
with open(nbf) as f: | |
nbb = nbformat.read(f, as_version=v) | |
nb.cells.extend(nbb.cells) | |
nbformat.write(nb, sys.stdout) | |
if __name__ == '__main__': | |
nbconcat(sys.argv[1:]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment