Skip to content

Instantly share code, notes, and snippets.

@amferraz
Created April 22, 2014 16:03
Show Gist options
  • Save amferraz/11184818 to your computer and use it in GitHub Desktop.
Save amferraz/11184818 to your computer and use it in GitHub Desktop.
Reads an ICS file and prints the events
# coding: utf-8
# File 'BrazilHolidays.ics' can be obtained here:
# http://www.mozilla.org/en-US/projects/calendar/holidays/
from icalendar import Calendar, Event
g = open('BrazilHolidays.ics','rb')
gcal = Calendar.from_ical(g.read())
for component in gcal.walk():
if component.name == "VEVENT":
print "---------------------------------"
print component.get('summary')
print dateutil.parser.parse(component.get('dtstart').to_ical())
print dateutil.parser.parse(component.get('dtend').to_ical())
print dateutil.parser.parse(component.get('dtstamp').to_ical())
g.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment