Since some months I’m using Toggl to track my work time, and I find it awesome! Toggl features a very powerful reporting system to have your timesheets filtered in many ways and exported in csv or pdf format, but I did not found the way to have an Excel timesheet as I like it.
But wait! Toggl features a very nice public API to access your time entries (and many more), so I wrote a simple Python script using the wonderful Requests and Xlsxwriter libraries.
First of all you need your Toggl API token, you can find it in your Toggl profile. Then you need your workspace id of interest. You can use a script like this to obtain it:
In my case I’ve just one workspace, but you can have many. Your workspace id (surprisingly) is in the ‘id’ property of the JSON object, 123456 in this example.
Now that you have your API token and your workspace id, here is the script:
You can call it like this:
./toggl_timesheet.py Google 2014-03-01 2014-03-31
Where Google is the name of the client you want to produce the timesheet for (you work for Google as a freelance, don’t you?) and the other parameters are the date range you want to extract times from. This will produce a nice Excel timesheet named Google_2014-03-01_2014-03-31.xlsx in the current directory, with a content similar to this:
A timesheet example
In bold you have your projects with the total time spent on the project, then you have all time entries related to the project. Enjoy!
Share:
You may also like:
Why I love Python – Expressiveness
Here is one of those little things that make me love Python: d = {'a': (1,2), 'b': (3,4)} for k, (a, b) in d.items(): print k, a, b Prints: a 1 2 b 3 4 How cool is that? 😉
A Django custom command to write model fields on an Excel file
Suppose you need to write down your model fields on an Excel file, for example to complement the documentation of your code. Django has built in functions to introspect models and fields of an app, and you can leverage this API to have the information you need. You can use …
Say you have a Django web application that you want to integrate with emails to make it possibile to send data and files to your web application over SMTP. The good news is that Python has a simple SMTP daemon in the standard library, together with modules to parse emails …
How to migrate your existing Django project to Heroku
Recently I had some fun with Heroku, the well known PaaS provider. I had a small personal Django project I use for invoicing that I ran locally with ./manage.py runserver when needed. That was a perfect candidate for the Heroku free plan because I need to access the app …