Jose's Blog

19.07.2015

Graphing the Time Stamps

Filed under: Programming — Tags: , , — admin @ 18:04

Remember here where I wrote about a python script that help me time stamp my activities. Now, I had an activity that I also wanted to graphically plot how much time I spent since I started on it. For this, I thought I make use of matplotlib and graph the progress graphically as a days-vs-(minutes spent/day) graph. I already had the csv file created by my time stamper and I wanted to use that data format to do this. But I wanted to have this more general, i.e. I wanted to just drag an drop any csv file created by the time stamping script and see the graph. To do this (I use windows!) I decided to allow window shell to drag and drop file into python scripts. This is done by adding to the windows registry as seen here:


Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Python.File\shellex\DropHandler]
@="{60254CA5-953B-11CF-8C96-00AA00B8708C}"

Now I can drag and drop csv files created by the stamper into this script to see the progress graph. The result would then look like so

work_graph

Enjoy!

16.05.2015

Time Stamping in Python

Filed under: Programming — Tags: — admin @ 18:35

I have written a script that allows me to time stamp my work during the day. I am sharing it with MIT license  here

I am mostly interested in having my timed activity saved in a csv file that will help me organize my time of the day. The script outputs a csv file with information about the date, time in which work has started, time in which work has ended, time difference of the two and the total time used for the day . So if you timed on for a day and then timed off at another day, then the script will detect it and ask you to give a time when you stopped your work in the day before. It is really merely to record my activity during that day and nothing more.  The script is text-based and if you run it, it will ask if you want to stamp time on or off. If you chose on and then the next time you run it (with the same data file) and ask to time off then it will accordingly do the computation and append the data file. If you chose time on (or time off) two consecutive time, then the script will ask you to first time off (resp. time on) your previous activity.  To run the script, I just place it in my common python library path (I only use Python 2.5 but I guess this would work for any newer version) and then I have a specific script that applied this script as a module in a folder where I have my specific activity. For instance if I have a folder in my PC where I often do my mathematical work, I place a python script with this content in it:

from time_stamp import timestamp
timestamp('./etc/math_timestamp.csv')

where the file ./etc/math_timestamp.csv is the relative filename from the place where the python script is located and where you want your data file (in this case math_timestamp.csv) to be saved. The data file is automatically created if it does not exist (only the directory should exist). Data file should not be tampered with, though it can be opened with any editor that understands csv (or a simple text editor). This allows me to time stamp fragmented  parts of my work while keeping my discipline and track for the amount of work I put for a specific task. For instance, I often would like to do 2 hours of math, 2 hours of chess and a few hours of other work and I use different data files for them (I don’t complete the 2 hours in one go). It definitely has kept me disciplined in the past few months and I have achieved more milestones by it. Simple but effective and yet not so sophisticated like a full fledged UI or something. That’s the way a minimalist like me wants it! :)

Powered by WordPress