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