[IPython-User] Reusable notebooks

Adam Hughes hughesadam87@gmail....
Mon Jul 23 15:45:02 CDT 2012


This is a good idea, thanks for the help.

Also, is there an "execute all" command from the notebook to rerun all
cells in a notebook from top to bottom in the current build?   I think this
would be a quick/dirty working way to do something like this before writing
the script that you mentioned.

~Adam

On Mon, Jul 23, 2012 at 4:00 PM, Thomas Kluyver <takowl@gmail.com> wrote:

> Hi Adam,
>
> This is a topic that's of interest to many of us working on IPython -
> how can we combine our quick, exploratory style of coding with
> something lasting that can be verified and replicated. We don't claim
> to have all the answers, but we think the notebook is a very useful
> step in that direction.
>
> On 23 July 2012 20:37, Adam Hughes <hughesadam87@gmail.com> wrote:
> > I created a notebook that takes in a datafile and does analysis to it
> based
> > on my very customized needs.  I would not share this with anyone;
> however, I
> > do want to reuse it for several different datafiles.  What I'm doing now
> is
> > manually changing the name of the datafile at the top of the notebook and
> > then just doing shift+enter to rerun everything one cell at a time.
> >
> > My question is how would I change this so that the notebook can be run
> all
> > at once with the datafile as an input.  Basically, how can I turn this
> into
> > a standalone script that is run from the command line for example?  Is
> this
> > possible in IPython?  If so, can you guys direct me to some examples or
> > discussion where it was already covered?  I'm having some trouble
> finding my
> > away around notebook resources; they seem scattered around the web a bit.
>
> I would suggest two possible approaches:
>
> - Staying in Python, refactor your data analysis so that calling a
> single function runs all the steps. Then running it for several
> datafiles is as simple as writing a for loop at the bottom of the
> notebook.
> - Save the notebook as a Python script (either via the 'File >
> Download as' menu, or start the notebook server with the --script
> option to get a .py file whenever you save a notebook). Then you can
> open it in an editor and adjust it from interactive-use code to
> something that you can run from the command line.
>
> I've used both of these approaches myself - what makes sense will
> depend on the kind of analysis you're doing, and what sort of workflow
> you want to fit it into - e.g. I have a Makefile to control parts of
> my data analysis, which lends itself to a script & file based
> approach.
>
> Best wishes,
> Thomas
> _______________________________________________
> IPython-User mailing list
> IPython-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-user
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/ipython-user/attachments/20120723/1b269b54/attachment-0001.html 


More information about the IPython-User mailing list