How can I create a copy of a notebok with all (or most) code cells emptied?

97 Views Asked by At

I want to create Jupyter notebooks for teaching, which shall be delivered in two versions:

  1. A full “textbook” with explanations in markdown cells and example code in code cells.
  2. As above, but with most code cells being empty such that the students have to type all the code themselves.

Obviously, I do not want to do this manually in Jupyter, so I need a way to automatically clear those code cells (exceptions are rare and can be marked somehow). Given that notebooks are stored as sources of Python objects, I could write a simple script to directly modify those. However, this feels like I am re-inventing the wheel instead f using some existing, dedicated method – which what I am seeking in this question.

I briefly considered using NBGrader. However, while I am quite confident that this could solve my problem, it seems overkill for this purpose and require extra effort to make things work.

1

There are 1 best solutions below

0
On

Have you checked out Chris Holdgraf's nbclean?