Ext: Added csv.py example extension

This commit is contained in:
Paul Beckingham 2016-05-21 20:55:40 -05:00
parent 42e4c174a9
commit a257ccacc8
2 changed files with 31 additions and 0 deletions

View file

@ -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.

27
ext/csv.py Executable file
View file

@ -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