Skip to content

Instantly share code, notes, and snippets.

@abondis
Created September 9, 2022 17:32
Show Gist options
  • Save abondis/e21eec5003f8babae4315e3b2a9c03d3 to your computer and use it in GitHub Desktop.
Save abondis/e21eec5003f8babae4315e3b2a9c03d3 to your computer and use it in GitHub Desktop.
quick csv to ics tasks
import csv
import datetime
tpl = """BEGIN:VCALENDAR
BEGIN:VTODO
SUMMARY:{summary}
DUE;TZID=America/Toronto:{due}T000001
CLASS:PRIVATE
END:VTODO
END:VCALENDAR"""
def f_time(d):
_date = datetime.datetime.strptime(d, '%Y-%m-%d')
return _date.strftime('%Y%m%d')
def parse(csv_file="tasks.csv"):
with open(csv_file, 'r') as tasks:
csvf = csv.DictReader(tasks)
for l in csvf:
due = l.get('Due', '')
if due:
due = f_time(due)
print(tpl.format(
summary=l.get('Subject', ''),
due=due
))
parse()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment