Weblog statistics

Tags: python

I had some fun last night whipping up some statistics for my weblog.

I’ve got some plain python code that takes a month/date/year directory structure, reads all the files in there and creates restructuredtext index.txt pages in every directory that list the files in there. That’s what turns into all those overview pages, for instance for March 2007 or for tag pages like for the Sorrento sprint in 2007.

That very same piece of code is what I use to make the statistics. Reading the weblog directory results in some nested Year, Month and Day objects, which I can of course call len() on. Coupled with a bit of code to generate google chart API URLs, I got pretty results pretty quick. See http://reinout.vanrees.org/weblog/statistics.html . Here’s an example:

http://chart.apis.google.com/chart?chs=600x300&chco=BBBBBB,4444FF&chd=t:11,8,7,14,8,9,1,4,5,2,9,5,25,20,20,7,22,25,18,19,10,15,7,17,4,5,11,4,17,4,9,1,0,9,7,6,12,10,4,19,2,8,7,4,4,5,3,9,3,10,8,1,6,24,3,6,21,2,4,3,13,2,7,1,15,11,2,2,5,6,7,1,2%7C11.0,11.0,10.0,11.0,10.0,10.0,8.0,8.0,7.0,6.0,7.0,7.0,10.0,11.0,13.0,12.0,14.0,15.0,16.0,16.0,15.0,15.0,14.0,14.0,13.0,11.0,11.0,10.0,11.0,10.0,10.0,8.0,7.0,7.0,7.0,7.0,8.0,8.0,8.0,9.0,8.0,8.0,8.0,7.0,7.0,6.0,6.0,6.0,6.0,7.0,7.0,6.0,6.0,9.0,8.0,8.0,10.0,9.0,8.0,7.0,8.0,7.0,7.0,6.0,7.0,8.0,7.0,6.0,6.0,6.0,6.0,5.0,5.0&chds=0,25,0,25&cht=lc&chdl=posts+per+month%7Cmoving+average&chxt=x,x,y&chxl=0:%7C04%7C10%7C05%7C12%7C05%7C1:%7C2003%7C2004%7C2006%7C2007%7C2009%7C2:%7C0%7C25