-
Notifications
You must be signed in to change notification settings - Fork 1
/
countDayOfWeek.py
67 lines (50 loc) · 1.38 KB
/
countDayOfWeek.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
56
57
58
59
60
61
62
63
64
65
66
67
import utilities
import random_generator
import numpy as np
import os
from sklearn.preprocessing import normalize
import random
import matplotlib.pyplot as plt
import pickle
import features
import re
from datetime import datetime
if __name__ == '__main__':
currentPath = os.getcwd()
oldpath = "../../alllogs/"
files = utilities.get_all_files(oldpath)
current_path = os.path.join(currentPath, oldpath)
DOW_list = [0,0,0,0,0,0,0]
total_time = 0
# daycount = 50
for afile in files:
# if daycount == 0:
# break
# daycount -= 1
print afile
dates = re.findall('\d{8}', afile)
if len(dates) != 1:
print dates, "\n\n"
else:
print dates
date_object = datetime.strptime(dates[0], '%Y%m%d')
dayOfWeek = date_object.weekday()
print dayOfWeek
for individual_files in os.listdir(os.path.join(current_path, afile)):
# print individual_files
with open(os.path.join(os.path.join(current_path, afile), individual_files), 'r') as f:
content = f.readlines()
count = len(content)
# print count
# if count > 300:
# print count, content
# print "\n\n\n"
# raw_input()
for line in content:
if line.strip() != None:
DOW_list[dayOfWeek] += 1
# print count_list
# print sum(count_list) / len(count_list)
# print max(count_list), min(count_list)
print DOW_list
pickle.dump(DOW_list, open("dayOfWeek.p", "wb"))