Commits

Ed Brannin committed c13227b

Extracting year, month, day as numbers in the output.

  • Participants
  • Parent commits a8599ab

Comments (0)

Files changed (1)

 import csv
+from datetime import datetime
 
 def handle(filename):
   reader = csv.reader(open(filename, "r"), delimiter=':', quoting=csv.QUOTE_NONE)
   writer = csv.writer(open(filename.replace(".txt", ".csv"), "w"))
-  # ['Fri Dec 14, 1900', 'Memorial ', 'White  ', 'John of the Cross, P & D']
+  # [1900, 12, 14, 'Fri Dec 14, 1900', 'Memorial ', 'White  ', 'John of the Cross, P & D']
   for date, type, color, name in reader:
+    dt = datetime.strptime(date, "%a %b %d, %Y")
     type = type.strip()
     color = color.strip()
-    writer.writerow([date, type, color, name])
+    writer.writerow([dt.year, dt.month, dt.day, date, type, color, name])
 
 def main(args):
   for arg in args: