Skip to content

Instantly share code, notes, and snippets.

@hpoul
Created August 31, 2014 20:45
Show Gist options
  • Select an option

  • Save hpoul/3cf635cd253fd29ffc9c to your computer and use it in GitHub Desktop.

Select an option

Save hpoul/3cf635cd253fd29ffc9c to your computer and use it in GitHub Desktop.
Convert WorkTrail work entries CSV files into Google Calendar CSV files / Get your Time Tracking results from https://worktrail.net/ to Google Calendar.
#!/usr/bin/python
# Converts work entries as exported by WorkTrail into a CSV format readable
# by Google Calendar.
#
# WorkTrail format as used in https://worktrail.net/
# -> Reports and Administration -> Work Reports -> Download as CSV
#
# Google Calendar format as described at
# https://support.google.com/calendar/answer/45656?hl=en
#
# Usage:
#
# 1. Download CSV from WorkTrail
# 2. execute this script with the CSV as input, and pipe stdout to csv file:
# python worktrail_to_gcal.py < reports.csv > googlecalendar.csv
# 3. in google calendar select 'Import Calendar' in the 'Other calendars' panel
# and select the generated .csv file.
import csv
import sys
worktrailinput = csv.reader(sys.stdin)
gcalout = csv.writer(sys.stdout)
# skip header
worktrailinput.next()
# print row for output
gcalout.writerow(['Subject', 'Start Date', 'Start Time', 'End Date',
'End Time', 'Description'])
# iterate through input file
for workentry in worktrailinput:
# parse input
(employee, start_date, end_date, duration, project, task, description) \
= workentry
# split start/end date into date and time.
start = start_date.split(' ')
end = end_date.split(' ')
# write output.
gcalout.writerow(['%s: %s' % (project, task),
start[0], start[1], end[0], end[1], description])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment