File: csv.py

package info (click to toggle)
timew 1.9.1%2Bds.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,436 kB
  • sloc: cpp: 30,358; python: 6,829; sh: 706; makefile: 15
file content (26 lines) | stat: -rwxr-xr-x 480 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/usr/bin/env python3

import json
import sys

# 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 = '"{}","{}"'.format(object['start'], (object['end'] if 'end' in object else ''))

    if 'tags' in object:
        for tag in object['tags']:
            line += ',"{}"'.format(tag)

    print(line)