Created
September 9, 2022 17:32
-
-
Save abondis/e21eec5003f8babae4315e3b2a9c03d3 to your computer and use it in GitHub Desktop.
quick csv to ics tasks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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