-
-
Save deseven/76d504fcc1c3ffa6e983ec504c3d0380 to your computer and use it in GitHub Desktop.
phpbb-parse-statistics
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
reload(sys) | |
sys.setdefaultencoding('utf-8') | |
if len(sys.argv) != 2: | |
print 'Usage:',sys.argv[0],'file_with_statistics' | |
sys.exit() | |
stats = {} | |
months = {'Jan':'01','Feb':'02','Mar':'03','Apr':'04','May':'05','Jun':'06','Jul':'07','Aug':'08','Sep':'09','Oct':'10','Nov':'11','Dec':'12'} | |
with open(sys.argv[1]) as f: | |
posts = f.readlines() | |
posts = [x.strip() for x in posts] | |
for post in posts: | |
month = post.split(' ')[1] | |
year = post.split(' ')[3] | |
month = months.get(month,'00') | |
key = year + '-' + month | |
if not stats.has_key(key): | |
stats[key] = 0 | |
stats[key] += 1 | |
for key in sorted(stats.iterkeys()): | |
print "%s\t%s" % (key,stats[key]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment