May 04, 2006

csv–to–ical in ruby

I've inheritted a list of SSL certificates that we maintain for various (about 30 odd) different servers. What's irksome about it is that I need to remember in advance to renew the certificates. The excel spreadsheet I've got isn't much good for that. Clearly, something that's calendar–based would be simpler. So, excel would give me a CSV easily enough, but how to get that into iCal / Evolution / google calendar / whatever ?

Simple. Watch:

require 'CSV'
require 'rubygems'
require_gem 'icalendar'

cal =

CSV::Reader.parse("65279certs.csv")) do |field|

cname = field[0]
serverType = field[2]
owner = field[1]
expiry = Date.strptime(field[10],"%d/%m/%Y")
certID = field[8]

reminder =
reminder.summary = cname +" Certificate expiry"
reminder.uid = certID
reminder.dtstart = expiry -14
reminder.dtend = expiry -14
reminder.description = "#{cname} (#{serverType}) expires #{expiry.to_s}\n#{owner}"
cal.add reminder

puts cal.to_ical

(please excuse the wonky indentation )

Then all I need to do is chuck the results on the web somewhere and not only can I subscribe to it, but so can anyone else who wants to know when their certificates expire.

Seems to me that that strikes the balance between a write–only perl one–liner, and a bazillion lines of java. Yay for ruby.

- No comments Not publicly viewable

Add a comment

You are not allowed to comment on this entry as it has restricted commenting permissions.

Most recent entries


Search this blog

on twitter...


    Not signed in
    Sign in

    Powered by BlogBuilder
    © MMXXI