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())
Sorry to hear it isn't working yet. I need to add a bunch of recurring events to a calendar so I'll try this locally soon and get back to you around early August. For example: I might try out python-dateutil instead of icalendar, add typer for file name input, and I may temporarily deploy a small azure function that does this. Not sure yet
In the meantime: there are three other strategies you could try.
sed
can add lines to files. Ensure it does it "globally" throughout the file instead of just once. The flag should beg
. For examplesed '/PATTERN/ i <LINE-TO-BE-ADDED>' FILE.txt
will "insert the line before every line where pattern match is found."Let me know how it goes. Best of luck!