forked from felipecruz/exemplos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
11_03_per_year.py
29 lines (23 loc) · 970 Bytes
/
11_03_per_year.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
from decimal import Decimal
from datetime import datetime, timedelta
totals = {2010:0, 2011:0, 2012:0, 2013:0, 2014:0, 2015:0}
def check_signature_interval(info, year_start_date, year_end_date):
try:
start_str_date = info[8]
end_str_date = info[9]
start_date = datetime.strptime(start_str_date, '%d/%m/%Y')
end_date = datetime.strptime(end_str_date, '%d/%m/%Y')
if start_date > year_start_date and start_date < year_end_date:
return 1
except Exception as e:
pass
return 0
for year in totals.keys():
start_date = datetime(year, 1, 1)
end_date = start_date + timedelta(days=365)
with open('data/data/ExecucaoFinanceira.csv', 'r') as data:
for line in data:
totals[year] += check_signature_interval(line.strip().split(';'),
start_date, end_date)
for year, signed in totals.items():
print("{} execuções assinadas em {}".format(signed, year))