[IPython-User] using iPython as a way to generate repetitive reports.
Sat Dec 1 15:48:52 CST 2012
I recently posted a question to Stack Overflow about the possibility of using iPython to generate reproducible, repetitive reports. (http://stackoverflow.com/questions/13614783/programatically-add-cells-to-an-ipython-notebook-for-report-generation) Lets say that I have a number of Pandas data frames and for each data frame I want to generate a series of tables , graphs and text, and then combine these into a report. I could use a templating system like Jinja but I am curious to know if I could use the iPython framework of ipython-notebook ---> nbconverter ---> pdf/html/etc for the purpose of generating all of the data analyses and the report into a single document.I have followed Thomas K.'s suggestion to use the get_ipython().set_next_input() function to add text to the next code block. For my idea to work, a few things would need to work:
from IPython.core.display import Image, display_png
x = Image(filename='test.png')
for i in range(3):
x = Image(filename='/Users/zachpowers/Downloads/pics/Sieve_1.png')
get_ipython().set_next_input('Thats What I am Talking About!')
if you run this you will see that there are a few different problems that you encounter.
1) you can't create Markdown cells
2) the display_png() function does not respect the .set_next_input() function so they are all displayed in the same output block in which they are called
3) the .set_next_input() function would need to be modified to track which code blocks it insert. It iterates over the loop and inserts a code block below the code block it sits in with the result that the code blocks are added in reverse order from expected.
4) there would need to be a way to hide the code-block that calls the rest of the functions.
5) you would probably still need a templating engine to generate interesting text of each markdown block
So in closing I think the python ---> nbconvert is a great tool and that it might potentially be useful for reproducible research of repetitive reports (say that five times fast). I think that a few tweaks to the ipython notebook might make this possible and that the benefit would be the creation of a single file from which analyses could be rerun and from which reports could be generated. However, upon writing up my thoughts I am not sure that this is easier than doing the analysis in one file and outputting the results via a separate templating system.
I hope some of the iPython community might find this line of thought to be useful and if so we could try to implement some of these ideas.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the IPython-User