Live notes: airport lounge writing python script

This is a live notes post. It is of very low interest to almost all readers, but I do believe that the more open my work is, the better that work goes.   These are posts mostly written for me, but if you arrived here from a search engine and it looks like I once had a problem that you have now then feel free to drop me a line and I’ll put things into order a little bit.

 

 

Sitting in the first class lounge watching the sun go down.
In a few hours I’ll be back at home pushing projects forward.  As a bit of prep I’m going to write a small python script.
The problem
 My todo list is formatted like so:
-18, t, 60, “Shattered scopeon azuleJoe code”, 2016-02-29 (Mon) – 12:01:01
3, 0, 0, “fix the formating of theWarnings on the azulejoe web”, 2016-03-11 (Fri) – 19:23:51
3, t, 20, “Read the arts grant guidance again”, 2016-02-29 (Mon) – 14:46:01
5, h,  5, “Floss”, 2016-02-29 (Mon) – 15:01:01
3, y, 15, “Transfer over the Supertitle posts from Joereddington.com”, 2016-02-29 (Mon) – 18:11:45
You’ll note that it has a date field.   I use that date field to work out how many tasks I have that are older than, respectively, 24 hours, three days, and one week. It normally looks like this:
However, I’ve been away for three weeks, and now it looks like this:

C057F4B1-21D2-4D2C-B463-7A33CD767B72

That’s right, literally everything is off the scale.
This makes it a little difficult.
The plan
I’d like to write a simple script that takes one off the date-of origin from each task.  That way I can run it whenever I have a day officially ‘off-grid’.
Let’s see what I have.
Ah, I wrote a command called ‘naSort’ (nextActions sort) that puts the actions in date order. That’s going to be useful.
————————————-
25/03/201619:17:14 GMT-7
I just remembered that I was going to use aText to help me split this up into manageable log entries.   I did, I did it like this:
Screen Shot 2016-03-25 at 19.17.02
and you are reading the first one.
————————————-
25/03/201619:23:14 GMT-7
Back to the code.  I’ve copied naSort over to na88 so I can have a play.  The existing code is simple:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/usr/bin/python
import csv
import time
import datetime
import operator
import io
import os
from na_lib_sorting import  get_sorted_actions
 
 
def print_sorted_tasks():
    tasklist=get_sorted_actions()
    for row in tasklist:
       toprint=  "%s, %s, %2s, \"%s\", %s" % (row[0].strip(),  row[1].strip(), row[2], row[3] , row[4])
       if len(row)==6:
        toprint=toprint+", "+row[5]
       print toprint
 
if __name__ == '__main__': print_sorted_tasks()
and at the very least this will mean the date is already parsed for me.   Wait, of course it doesn’t mean that.  It just means the date string is parsed out.  I need the library file: na_lib_sorting.
————————————-
25/03/201619:29:06 GMT-7
The library file has the answer: ” datetime.datetime.strptime(item[4], TIMESTAMP_FORMAT))
————————————-
25/03/201619:37:30 GMT-7
Hmm, I’ve alteed na88 to printout just the date,  but it’s still producing a string rather that the data-structure I want.  Time for a quick Google.
————————————-
25/03/201619:43:11 GMT-7
The ever excellent Stackoverflow (via  this answer that I have dutifully upvoted) has provided both the explanation I needed and the code for the next step.  Excellent.   Basis proof of concept now running.
————————————-
25/03/201619:46:40 GMT-7
Working script now active.  yay!
A couple of notes for the future. The number of days should be taken from the command line, defaulting to zero. This would let me just add the file to the naSort code and reduce the number of files.
Let’s see if I can make it work.
————————————-
26/03/201602:57:06 GMT
As an aside – even thought I’m in the departure lounge at Vancouver airport.  I’ve just switched my laptop over to UK time – it was amazing how I instantly felt more tired when I saw evidence it was three in the morning.  (Flux activating at the same time didn’t help)
————————————-
26/03/201603:35:52 GMT
Now,  after a short break, it becomes time to put the todo list in order.  It’s currently 330 items strong, bit a lot of those are automatically generated ones that only come up in a working week and that have been mounting up in my absence.    I’ll deal with those first.
And indeed, once I had, we were left with only 127 left  (which makes me think I should keep an eye on the amount of overhead that I’m dealing with on a daily basis)
————————————-
26/03/201603:55:36 GMT
I used the na88 script to bring things back into line with where they were when I left, but appear to have discovered a bug – stay tuned.
————————————-
26/03/201604:07:58 GMT
Now fixed.  I’ve added a task to put the script properly in the relevent git repo when I can work onilne.
 The score look a lot more reasonable now.  But there are still 62 of them that are over a week old even with this system. It’s also time to gather up all of the tasks that are on phones, laptops, scraps of paper, and business cards and put them into the main list.  But I am getting a little tired.

Leave a Reply