-
Notifications
You must be signed in to change notification settings - Fork 0
/
lenacha.py
55 lines (40 loc) · 1.23 KB
/
lenacha.py
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
55
import pyclan as pc
import csv
import os
# start_dir = "data/6_7_lenacha"
start_dir = "data/idslabel_files"
def end_time(filepath):
clan_file = pc.ClanFile(filepath)
for line in reversed(clan_file.line_map):
if not line.is_tier_line:
continue
else:
return line.offset
print
def sum_time(filepath):
clan_file = pc.ClanFile(filepath)
total = 0
for line in clan_file.line_map:
if line.is_tier_line:
total += line.offset - line.onset
return total
def walk():
times = []
for root, dirs, files in os.walk(start_dir):
for file in files:
print file
path = os.path.join(root, file)
end = end_time(path)
# sumd = sum_time(path)
# print (file[:5], end, sumd)
# times.append((file[:5], end, sumd))
times.append((file[:5], end))
return times
with open("idslabel_bergelson_times.csv", "wb") as out:
times = walk()
writer = csv.writer(out)
# writer.writerow(["file", "end_stamp_lenacha", "sum_stamp_lenacha"])
writer.writerow(["file", "time"])
writer.writerows(times)
# clan_file = pc.ClanFile("data/6_7_sparsecode/03_07_sparse_code.cha")
print