Created
August 30, 2012 18:35
-
-
Save shanewholloway/3536969 to your computer and use it in GitHub Desktop.
Convert Billings.app exported slip ".bex" file into Freckle-style CSV
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 glob | |
import plistlib | |
clientProject = 'My Project' | |
for filename in glob.glob("*.bex"): | |
root = plistlib.readPlist(filename) | |
with open(filename+'.csv', 'wb') as out: | |
out = csv.writer(out) | |
out.writerow(['Date', 'Person', 'Client/Project', 'Minutes', 'Tags', 'Description', 'Billable', 'Invoiced', 'Invoice Reference']) | |
for slip in root.objects: | |
slip = dict(slip) | |
desc = slip.pop('name') | |
who = slip.pop('owner.name') | |
timeEntries = slip.pop('timeEntries') | |
print who, desc | |
print slip | |
tags = 'from_billings_app' | |
for te in timeEntries: | |
date = te.startDateTime.date() | |
delta = (te.endDateTime - te.startDateTime).total_seconds() | |
minutes = int(delta/60) | |
if minutes>=1: | |
out.writerow([date, who, clientProject, minutes, tags, desc,'yes','no',None]) |
Does this work?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It's very rough, but it let me give freckle a real try using my data!