Skip to content

Commit

Permalink
Fixing date format, csv doesn't use AM/PM and uses 24-hr
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-yu committed Sep 21, 2014
1 parent 817eeda commit 5bcae04
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions toronto_fire/management/commands/import_incidents.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ def handle(self, *args, **options):
# We'll count the units listed
incident.number_of_units = len(filter(None, incident_row[10].split(','))) if ',' in incident_row[10] else 0

incident.start_datetime = datetime.strptime(incident_row[5],'%Y-%m-%d %I:%M:%S %p')
incident.arrival_datetime = datetime.strptime(incident_row[11],'%Y-%m-%d %I:%M:%S %p')
incident.end_datetime = datetime.strptime(incident_row[12],'%Y-%m-%d %I:%M:%S %p')
incident.start_datetime = datetime.strptime(incident_row[5],'%Y-%m-%d %H:%M:%S')
incident.arrival_datetime = datetime.strptime(incident_row[11],'%Y-%m-%d %H:%M:%S')
incident.end_datetime = datetime.strptime(incident_row[12],'%Y-%m-%d %H:%M:%S')

incident.save()
4 changes: 2 additions & 2 deletions toronto_fire/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ def setUp(self):
# Create a csv file with a single row
import csv
header_row = ['PrimeStreet','CrossStreet','LookupIntersection','Latitude','Longitude','DispatchTime','IncidentNo','IncidentType','AlarmLevel','Area','DispatchedUnits','IncidentLoadTime','MAX(FireDispatchUpdate)']
test_row = ['MOUNT PLEASANT RD', 'TT LAWRENCE AVE E / WANLESS AVE','MOUNT PLEASANT RD and LAWRENCE AVE E Toronto','43.7261546','-79.3971892','2011-01-01 12:07:23 AM',\
'F11000011','Carbon Monoxide - Non Medical','1','131','A131,','2011-01-01 12:07:23 AM','2011-01-01 12:07:23 AM']
test_row = ['MOUNT PLEASANT RD', 'TT LAWRENCE AVE E / WANLESS AVE','MOUNT PLEASANT RD and LAWRENCE AVE E Toronto','43.7261546','-79.3971892','2011-01-01 00:07:23',\
'F11000011','Carbon Monoxide - Non Medical','1','131','A131,','2011-01-01 00:07:23','2011-01-01 00:07:23']

test_csv = open('unittest.csv', 'wb')
wr = csv.writer(test_csv, quoting=csv.QUOTE_ALL)
Expand Down

0 comments on commit 5bcae04

Please sign in to comment.