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())
If I wrote this today then I would make the input/output file path user-provided parameters using typer
As it stands today: the input file is hardcoded as
noRecur.ics
and the output file is hardcoded aswithRecur.ics
. The python currently requires thatnoRecur.ics
is in the same directory as the python file and it probably works best ifwithRecur.ics
doesn't already exist (so delete or renamewithRecur.ics
if you run it multiple times)Let me know how it goes. I'm happy to help further and make it work better.