Created
April 22, 2014 16:03
-
-
Save amferraz/11184818 to your computer and use it in GitHub Desktop.
Reads an ICS file and prints the events
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
# 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