-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreport.py
More file actions
48 lines (39 loc) · 1.5 KB
/
report.py
File metadata and controls
48 lines (39 loc) · 1.5 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
# -*- coding: utf-8 -*-
def removeQuotes(line):
while line.find('"') != -1:
line = line.replace('"', '')
return line
def filter(fileName="report.csv", departmentsList=["Технические"], exclusionsList = ["Need info", "On hold"]):
fh = open(fileName,'r')
report = list()
for line in fh:
for dep in departmentsList:
if dep.lower() in line.lower():
if removeQuotes( line.split(',')[1] ) not in exclusionsList:
report.append( removeQuotes( line.strip() ) )
fh.close()
report.sort()
count = 0
totalCount = 0
department = None
result = 'Department\tStatus\tTotal\tLast Activity\n'
for l in report:
if department is None:
department = l[:l.find(',')]
count = int(l.split(',')[2])
result = result + "\t".join(l.split(',')) + '\n'
continue
elif department == l[:l.find(',')]:
count += int(l.split(',')[2])
result = result + "\t".join(l.split(',')) + '\n'
elif department != l[:l.find(',')]:
totalCount += count
result = result + "\t\t" + str(count) + "\t" + '\n'
result = result + "\t".join(l.split(',')) + '\n'
department = l[:l.find(',')]
count = int(l.split(',')[2])
result = result + "\t\t" + str(count) + "\t" + '\n'
totalCount += count
result = result + "\tAbsolute count:\t" + str(totalCount) + "\t" + '\n'
return result
# print filter()