diff --git a/ext/README b/ext/README index 2b1f6f01..43894e02 100644 --- a/ext/README +++ b/ext/README @@ -9,3 +9,7 @@ debug.py on-modify.timewarrior This is a Taskwarrior hook script that will integrate Timewarrior. +csv.py + This extension exports the data in CSV format, with a variable number of tag + fields. + diff --git a/ext/csv.py b/ext/csv.py new file mode 100755 index 00000000..de8ee77a --- /dev/null +++ b/ext/csv.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python + +import sys +import json + +# Skip the configuration settings. +for line in sys.stdin: + if line == '\n': + break; + +# Extract the JSON. +doc = '' +for line in sys.stdin: + doc += line + +total_active_time = 0 + +j = json.loads(doc) +for object in j: + line = '"%s",' % object['start'] + line +='"%s"' % (object['end'] if 'end' in object else '') + + if 'tags' in object: + for tag in object['tags']: + line += ',"%s"' % tag + + print line