Attached is my Ruby script for parsing log files I keep at work. I have to complete a weekly report, and this forms the basis of that; as I don't keep regular office hours (I flexi-work around child care), it also helps me keep track of the hours I've worked.
The basic principle of operation is as follows:
parse_work_log <file name> > summary.out on the file to produce a log of what I've donesummary.out file into an email I send roundThe format of the file is deliberately simple to make it easy to maintain; there are a handful of formatting rules. An example is shown below.
********** 2009-12-21 09:30-12:00 Researching this and that #research 12:00-13:00 -Lunch 13:00-14:00 More research 14:00-18:00 Writing some application #coding ********** 2009-12-22 09:30-10:00 Admin #Admin 10:00-10:15 -Break 10:00-12:00 Found out something rather marvellous #Very important research 12:00-12:45 -Lunch 12:45-18:00 Writing another application #coding ********** +NEXT Have lots of fun banging my head on a brick wall +NEXT Reinstall my operating system
Which, when parsed, produces this on stderr:
************************************* Worked 15.25 hours
And this on stdout:
************************************* This week: Admin: * Admin Very important research: * Found out something rather marvellous coding: * Writing some application * Writing another application research: * Researching this and that ************************************* Next: * Have lots of fun banging my head on a brick wall * Reinstall my operating system
Notes on formatting:
HH:MM-HH:MM <...whitespace...> <text> <#optional tag>\n-Lunch or -Break# creates a tagged entry which gets included in the report; it appears as a bullet point with the tag as its heading; any entries with the same tag get aggregated under a single heading; tags and entries appear in the order they occur in the file+NEXT gets listed in the Next section at the end; tags don't work on this (could, but don't at the moment)It is pretty primitive, but it does the job for me.
Installation: there isn't any, really. It works from the command line and needs Ruby. The licence? BSD, I guess.
| Attachment | Size |
|---|---|
| parse_work_log | 1.63 KB |
Comments
cute script!
I love things that make lists.. this looks really useful.. must be my virgo tendancies coming out!
good job
Interesting script. I always learn a lot from your posts and really appreciate it! I wish you a Happy New Year. Regards, Martin
reply
This page can easily provide good information that will people, prefer individuals. With any luck in which you’ve composed may be a great deal more effective to go on to publish your own sales messages. Are grateful for this specific really educational ad. solang