Moved book generation code into PDF directory
Start of a reorganization of files to make book more browable and to reduce the size of links to chapters.
This commit is contained in:
26
pdf/nbmerge.py
Normal file
26
pdf/nbmerge.py
Normal file
@@ -0,0 +1,26 @@
|
||||
"""
|
||||
usage:
|
||||
|
||||
python nbmerge.py A.ipynb B.ipynb C.ipynb > merged.ipynb
|
||||
"""
|
||||
|
||||
import io
|
||||
import os
|
||||
import sys
|
||||
|
||||
from IPython.nbformat import current
|
||||
|
||||
def merge_notebooks(filenames):
|
||||
merged = None
|
||||
for fname in filenames:
|
||||
with io.open(fname, 'r', encoding='utf-8') as f:
|
||||
nb = current.read(f, 'json')
|
||||
if merged is None:
|
||||
merged = nb
|
||||
else:
|
||||
merged.worksheets[0].cells.extend(nb.worksheets[0].cells)
|
||||
merged.metadata.name += "_merged"
|
||||
print current.writes(merged, 'json')
|
||||
|
||||
if __name__ == '__main__':
|
||||
merge_notebooks(sys.argv[1:])
|
||||
Reference in New Issue
Block a user