download
raw
596 Bytes
"""
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:])

Xet Storage Details

Size:
596 Bytes
·
Xet hash:
87d1ab665f63e069c46989798695b013d46faf86bc28dccc25ca20b5c30901ec

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.