One method of quickly creating a lot of events in google calendar is to import a CSV file. However, there is no support for directly adding "recurring" events (birthdays, anniversaries, etc). Here's the workarond.
- create csv file with events (no recurring)
- import csv into a new, temporary google calendar
- export temporary google calendar to an ics file
- edit ics file to change events into recurring
- import ics file into a new, permanent google calendar.
- delete temporary google calendar
The CSV format can be found at https://support.google.com/calendar/answer/37118?hl=en
4a. manually by adding RRULE:FREQ=YEARLY
between each set of VEVENT
begin/close statements. For example:
BEGIN:VEVENT
DTSTART;VALUE=DATE:20180520
DTEND;VALUE=DATE:20180521
RRULE:FREQ=YEARLY
...
END:VEVENT
or
4b. automatically by running this python
import icalendar
import os
def make_recurring():
directory = os.path.dirname(__file__)
with open(os.path.join(directory, 'noRecur.ics'), 'r') as fr:
data = fr.read()
cal = icalendar.Calendar.from_ical(data)
for event in cal.subcomponents:
if 'RRULE' not in event.keys():
event.add('rrule', {'freq': ['YEARLY']})
with open(os.path.join(directory, 'withRecur.ics'), 'wb') as fw:
fw.write(cal.to_ical())
Thank you for the code, it help me a lot!! One question, I've tried different ways but I didn't get it to work with recurring UNTIL. I always get an error stating that I should use datetime, but it does not work.
Thank you