-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathohslocations2csv.py
More file actions
55 lines (41 loc) · 1.23 KB
/
ohslocations2csv.py
File metadata and controls
55 lines (41 loc) · 1.23 KB
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#Takes an output file from FuriosTools batchfetch and creates a histogram of # of reports per time slice
#Optional third argument is the time slice length in seconds
import sys
import re
import datetime
import dateutil.parser
infile = open(sys.argv[1], "r")
outfile = open(sys.argv[2], "w")
slice = 60
if(len(sys.argv) == 4):
slice = int(sys.argv[3])
lines = infile.readlines()
infile.close()
reports = []
#Extract all datetimes
for i in range(len(lines)):
if not "speed" in lines[i]:
continue
reported = lines[i+1].strip()
date = lines[i+2].strip()[9:-1]
accuracy = lines[i+3].strip()
confidence = lines[i+4].strip()[9:-1]
reports.append((dateutil.parser.parse(date), dateutil.parser.parse(reported), re.split("<|>", lines[i])[1], accuracy, confidence))
#Sort
reports.sort()
outfile.write("Time Seen,Time Reported,Lat,Long,Report Delay,Accuracy,Confidence")
outfile.write("\n")
for (s, r, l, a, c) in reports:
outfile.write(str(s))
outfile.write(",")
outfile.write(str(r))
outfile.write(",")
outfile.write(l)
outfile.write(",")
outfile.write(str(r-s))
outfile.write(",")
outfile.write(a)
outfile.write(",")
outfile.write(c)
outfile.write("\n")
outfile.close()