0

End goal I would like to parse an ical file and get all final events that appear on the calendar. I thought I had easily accomplished this but realized I was not properly capturing recurring events. I was simply counting the number of times the event appeared in the ical file but recurring events may appear once in the ical file and then say something like "FREQ=DAILY;COUNT=10". So my script would only count it once but really it should be 10 times.

The process I am trying is

  1. Check if the event is recurring from "RRULE"
  2. Count how many times it is occurring
  3. Get the excluded dates from "EXDATE" and subtract this value

When I try component.get('EXDATE') the output I get is <icalendar.prop.vDDDLists object at 0x7fc020d989a0> but I do not know how to convert this to the date information.

If there is an easier way to get the end goal please let me know.

Sample Script

g = open('calendar.ics','rb')
gcal = Calendar.from_ical(g.read())
for component in gcal.walk():
    #Makes empty list to append info for each row
    row = []

    #Finds each event
    if component.name == "VEVENT":

        #Summary contains the name of the event
        summary = component.get('summary')
        freq = component.get('RRULE')

        #HOW DO I WORK WITH THIS FORMAT
        exDate = component.get('EXDATE')


        #Gets start date information
        dtstart = component.get('dtstart').dt
        startDate = dtstart.strftime('%Y-%m-%d')

        #Adds info to list
        row.extend([startDate, summary])

0 Answers0