13

I am able to export the entire notebook as HTML, but I would like to export just a single cell, together with its output.

Is there some way of doing this?

Matt
  • 27,170
  • 6
  • 80
  • 74
P i
  • 29,020
  • 36
  • 159
  • 267
  • 2
    I have same question: is there a way to export a selected subset of IPython cells, for example to create a summary HTML report? – Stefaan Nov 26 '15 at 09:51
  • See related discussion and options at [Hide input cells · Issue #534 · jupyter/notebook](https://github.com/jupyter/notebook/issues/534) – nealmcb Jan 15 '17 at 06:10
  • Also, see http://stackoverflow.com/questions/26494747/simple-way-to-choose-which-cells-to-run-in-ipython-notebook-during-run-all – Gordon Bean Mar 29 '17 at 17:33

1 Answers1

4

One way to do this is to use a custom preprocessor.

I explain how to do this briefly in response to Simple way to choose which cells to run in ipython notebook during run all.

To summarize: you can extend nbconvert.preprocessors.ExecutePreprocessor to create a preprocessor that checks cell metadata to determine whether that cell should be executed and/or output.

I use Jupyter Notebooks for report generation all the time, so I wrote a collection of custom processors to extend nbconvert behavior:

  • meta-language to determine what cells get executed and included in the final report (if/else logic on entire notebook sections)
  • executing code in markdown cells
  • removing code cells from output.
  • taking input arguments from the command line

I haven't had time to wrap these in an distributable extension, but you can see the code here: https://gist.github.com/brazilbean/3ebb31324f6dad212817b3663c7a0219.

Please feel free to use/modify/do-great-things with these examples. :)

Community
  • 1
  • 1
Gordon Bean
  • 4,272
  • 1
  • 32
  • 47