Message Boards Message Boards

[Tips] Extract Input Code from Long Notebooks

Posted 5 years ago

Recently both our users and developers have contributed a large amount of good articles and demonstrations on Community. It is a great adventure to read through the notebooks and play around the codes. Sometimes you may want to create another notebook along side with only input cells (executable parts only), so you can quickly run all notebook quickly and view the results avoiding long scroll.

Here are two ways you can make it happen:

at

Or you can

  • Put the following script in the top line of your notebook from which you need to extract input codes. This method is more general because you can choose any style you like in the Cases function, note limit to Input style. And Alternative lets you pick multiple styles at the same time:

    this = EvaluationNotebook[];
    new = NotebookGet[EvaluationNotebook[]];
    new = Cases[new, Cell[__, "Input" | "Code", ___], \[Infinity]];
    nb = CreateDocument[new];
    SelectionMove[nb, Next, Cell];
    NotebookDelete[nb];
    Pause[3];
    NotebookClose[this] 
    

code

POSTED BY: Shenghui Yang

enter image description here -- you have earned Featured Contributor Badge enter image description here

Your exceptional post has been selected for our editorial column Staff Picks http://wolfr.am/StaffPicks and Your Profile is now distinguished by a Featured Contributor Badge and is displayed on the Featured Contributor Board. Thank you!

POSTED BY: EDITORIAL BOARD
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract