Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. import csv
  2. from sys import argv
  3. from datetime import date
  4.  
  5. script_name, filename = argv
  6.  
  7. class cases():
  8.     def __init__(self,filename):
  9.         self.case_file = open(filename, 'r')
  10.         self.the_list = []
  11.         self.case_csv_reader = csv.reader(self.case_file)
  12.  
  13. class opencases(cases):
  14.     the_list = []
  15.     def read_all_cases(self):
  16.         for line in self.case_csv_reader:
  17.             self.the_list.append(line)
  18.  
  19. class closedcases(cases):
  20.     def read_closed_cases(self):
  21.         self.the_list = []
  22.         for line in self.case_csv_reader:
  23.             if line[1] == '':
  24.                 pass
  25.             else:
  26.                 self.the_list.append(line)
  27.         self.the_list.pop(0)
  28.         return self.the_list
  29.  
  30. def subtract_dates():
  31.     c = closedcases(filename)
  32.     list_closed_cases = c.read_closed_cases()
  33.     converted_startdate = []
  34.     converted_enddate = []
  35.     closed_days = []
  36.     for l in list_closed_cases:
  37.         index = 0
  38.         startdate = l[0]
  39.         split_startdate = startdate.split('/')
  40.         print split_startdate
  41.         for m in split_startdate:
  42.             split_startdate[index] = int(m)
  43.             index += 1
  44.            
  45.         print split_startdate
  46.         converted_startdate.append(split_startdate)
  47.     for l in list_closed_cases:
  48.         index = 0
  49.         enddate = l[1]
  50.         split_enddate = enddate.split('/')
  51.         print split_enddate
  52.         for m in split_enddate:
  53.             split_enddate[index] = int(m)
  54.             index += 1
  55.  
  56.         print split_enddate
  57.         converted_enddate.append(split_enddate)                
  58.    
  59.     print converted_startdate
  60.     print converted_enddate
  61.    
  62.     index = 0    
  63.     for l in list_closed_cases:
  64.         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
  65.         index += 1
  66.         closed_days.append(y)
  67.    
  68.     return closed_days
  69.    
  70. def test_cases():
  71.     c = closedcases(filename)
  72.     list_closed_cases = c.read_closed_cases()
  73.     print list_closed_cases
  74.     f = raw_input()
  75.     converted_startdate = []
  76.     converted_enddate = []
  77.     closed_days = []
  78.     for l in list_closed_cases:
  79.         startdate = l[0]
  80.        
  81.    
  82. closed = subtract_dates()
  83. print closed