Reputation: 865
Basically my goal is I want to be able to take an ics file as the input and be able to parse out a date's events and then from each event break down the information from it. I have been attempting to figure it out with http://pypi.python.org/pypi/icalendar
This is as far as I've gotten..
from icalendar import Calendar, Event
cal = Calendar.from_ical(open('Work.ics','rb').read())
for component in cal.walk():
print component
Upvotes: 2
Views: 6241
Reputation: 4785
depending what you mean by 'parse events dates': should you mean the ability to know all instances dates (RRULE, RDATE, EXDATE) you could also try pyICSParser a ics events enumerator, to list instances of events:
mycal = icalendar.ics()
mycal.local_load("work.ics")
dates = mycal.get_event_instances(start,end)
#dates will contain the json with all explicit dates of the events spec'ed by the iCalendar file
PS: disclaimer - I wrote/still writing this module and it so far only handles DATE not DATE-TIME properties values.
Upvotes: 3
Reputation: 503
Maybe try:
with Calendar.from_ical(open("work.ics")) as FileObj:
for components in FileObj:
print components
This should print every line in file (untested).
Upvotes: 0