mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-06-26 10:54:28 +02:00
Ext: Added csv.py example extension
This commit is contained in:
parent
42e4c174a9
commit
a257ccacc8
2 changed files with 31 additions and 0 deletions
|
@ -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
27
ext/csv.py
Executable 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
|
Loading…
Add table
Add a link
Reference in a new issue