import csv
from sys import argv
from datetime import date
script_name, filename = argv
class cases():
def __init__(self,filename):
self.case_file = open(filename, 'r')
self.the_list = []
self.case_csv_reader = csv.reader(self.case_file)
class opencases(cases):
the_list = []
def read_all_cases(self):
for line in self.case_csv_reader:
self.the_list.append(line)
class closedcases(cases):
def read_closed_cases(self):
self.the_list = []
for line in self.case_csv_reader:
if line[1] == '':
pass
else:
self.the_list.append(line)
self.the_list.pop(0)
return self.the_list
def subtract_dates():
c = closedcases(filename)
list_closed_cases = c.read_closed_cases()
converted_startdate = []
converted_enddate = []
closed_days = []
for l in list_closed_cases:
index = 0
startdate = l[0]
split_startdate = startdate.split('/')
print split_startdate
for m in split_startdate:
split_startdate[index] = int(m)
index += 1
print split_startdate
converted_startdate.append(split_startdate)
for l in list_closed_cases:
index = 0
enddate = l[1]
split_enddate = enddate.split('/')
print split_enddate
for m in split_enddate:
split_enddate[index] = int(m)
index += 1
print split_enddate
converted_enddate.append(split_enddate)
print converted_startdate
print converted_enddate
index = 0
for l in list_closed_cases:
y = (date(converted_enddate[index][2], converted_enddate[index][0], converted_enddate[index][1]) - date(converted_startdate[index][2], converted_startdate[index][0], converted_startdate[index][1])).days
index += 1
closed_days.append(y)
return closed_days
def test_cases():
c = closedcases(filename)
list_closed_cases = c.read_closed_cases()
print list_closed_cases
f = raw_input()
converted_startdate = []
converted_enddate = []
closed_days = []
for l in list_closed_cases:
startdate = l[0]
closed = subtract_dates()
print closed