Created
March 13, 2019 09:17
-
-
Save alancwoo/9e9bf5a3d0fa2859b7f84d1f29413082 to your computer and use it in GitHub Desktop.
Print travel dates from Google Calendar export
This file contains hidden or 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
#!/usr/bin/python3 | |
""" Travel Calendar Parser | |
Export ics from Google Calendar and pass filename as argument | |
pip3 install ics | |
python3 travel_dates.py input_file.ics | |
""" | |
import sys | |
from ics import Calendar | |
DATE_FORMAT = "%d-%m-%Y" | |
filename = sys.argv[1] | |
file = open(filename, "r") | |
c = Calendar(file) | |
eventsSorted = sorted(c.events, key=lambda x: x.begin) | |
for e in eventsSorted: | |
if e.all_day: | |
print("{:<15} | {} → {} | {:>7}".format(e.name, e.begin.strftime(DATE_FORMAT), e.end.strftime(DATE_FORMAT), str(e.duration).replace(", 0:00:00", ""))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment