Using Python to analyse last years forum logs. Good coding practise discussion.
Archive - Originally posted on "The Horse's Mouth" - 2014-01-01 12:25:50 - Graham EllisThe coming of a new year is a time to look forward - and also to look back. Yes, I know we look back between Christmas and the New Year - and indeed I did so - but some things such as completing the analysis of results for the year just gone have to wait until after the witching hour of midnight!
I anticipate training a lot of people on Python this year, and with that training to be instructing them on good programming practise - from commenting and variable naming standards through to good design and structure. And "structure" means separating the various pieces of code out into logical, robust, testable and re-usable sections which in the case of Python (and most other modern langauges) means objects.
So - pulling those two elements together, I wrote my first program of 2014. It analyses the number of new posts, and the number of new subjects, on the First Great Western Coffee Shop forum. This is a forum which I look after, as a passenger of First Great Western - it's completely independent of the company and although it started off being much more critical than supportive, times have changed and so has the suitablity of the FGW product for its customers - it's now much better - so we're now much more supportive than critical. Interestingly, where we are constructively critical, we even find our suggestions taken up.
How have the posts on the forum gone? My program (source code [here], data file [here]) tells me:
In year 2007 there were 7330 new posts in 1320 new topics
In year 2008 there were 25211 new posts in 2747 new topics
In year 2009 there were 25925 new posts in 1892 new topics
In year 2010 there were 24293 new posts in 2111 new topics
In year 2011 there were 21836 new posts in 1807 new topics
In year 2012 there were 18682 new posts in 1657 new topics
In year 2013 there were 22285 new posts in 1533 new topics
and if you want to read what that means to the forum, I've talked about it [here].
The Python program's commented, so I won't add a further description here. But I will suggest that you take a look at Learning to Program in Python which runs 5 times in 2014 if you're a newcomer to Python, Python programming if you have prior programming experince (also scheduled 5 times in 2014) or Intermediate Python which is scheduled 4 times if you've already done some Python and want a quick brush up on the basics, before a more serious study of some slightly more advanced stuff.
If you have a group of delegates who you wish to train, please get in touch - we can run private courses ar our centre, or on site at your offices if that makes better sense for you - and those courses can be tailored to meet your specific needs. See [here] for more details, and a link to our quotation system. 2013 saw me training in London, Manchester, Bristol, Stevenage, Cambridge, Milton Keynes... and many more places as far afield as Switzerland. For 2014, I'm already booked for London, Liverpool, Manchester and Preston... that's during this month of January, and I can add in YOUR town too!