How long have I been doing this?
January 11, 2007 12:18 AM   RSS feed for this thread Subscribe

Is there a way to analyse calendar (iCal) data that I've accumulated over the past year? For Example, Total hours spent doing X, or Total hours spent in Category A.

I'm willing to export my data to another program (entourage / outlook / FileMaker) if thats what I have to do.

Any suggestions would be great. Thanks.
posted by psyward to work & money (4 comments total) 1 user marked this as a favorite
I don't know of any pre-built solutions, but with a little knowledge of scripting and some regular expressions, you could whip something up in a few hours. The .ics format is plain-text, so it's easy to parse with perl, python, or whatever other favorite language you have.
posted by chrisamiller at 12:58 AM on January 11, 2007


If you can learn Ruby it has a nice looking iCal library that can parse iCal files: http://icalendar.rubyforge.org
posted by PenDevil at 3:48 AM on January 11, 2007


I know a perl hacker at school who parsed a bunch of iCal files for a project we were working on. It'll be java. We then ran a bunch of statistical machine learning type stuff on it. I'll see if I can dig it up for you. But no, there's nothing that's already built / has a nice gui front end that I know of. Onlife is different, but might be interesting to look at (for your upcoming year).
posted by zpousman at 7:41 AM on January 11, 2007


Thanks all. I never considered parsing the ics file.

A quick search brought up an applescript that does what I need it to. Applescript is nice and easy to understand, so I was able to customise the export to CSV.


Begin Code
tell application "iCal"
set secInHour to 3600
set outputStr to "
"
set totalHours to 0
set today to current date
set start to ((current date) - (secInHour * 24 * 105))
set weeksHours to every event of calendar "work" whose start date is greater than start

repeat with evt in weeksHours
set duration to (end date of evt) - (start date of evt)
set sDate to start date of evt as date
set eDate to end date of evt as date
set totalHours to totalHours + duration / secInHour

set sMin to minutes of sDate
if minutes of sDate = 0 then set sMin to "00"

set eMin to minutes of sDate
if minutes of eDate = 0 then set eMin to "00"

set timeStr to (year of sDate & " " & month of sDate & " " & day of sDate & " " & weekday of sDate & " " & hours of sDate & ":" & sMin & " - " & hours of eDate & ":" & eMin) as string
-- make columns all line up nice
repeat until length of timeStr > 28
set timeStr to timeStr & " "
end repeat
set timeStr to timeStr & " " & duration / secInHour & "
"
set outputStr to outputStr & timeStr
end repeat
end tell


outputStr
End Code

posted by psyward at 12:38 PM on January 11, 2007


« Older Advice on buying an LCD tv....   |   How can I turn off a hot-water... Newer »
This thread is closed to new comments.