-
Notifications
You must be signed in to change notification settings - Fork 0
/
decode-month.py
48 lines (40 loc) · 1.51 KB
/
decode-month.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/python
import csv, os, pprint
# STEP 2 of lacrashbot script package
#this script creates a new csv containing one column with the months spelled out.
#The column should then be pasted into the working LACinjury2014.csv
#It's important to use this three letter month spelling, because that's what the unix %b uses
#TODO: create a column header. I don't know how to do that.
test_file = './LACinjury2014.csv'
csv_file = csv.DictReader(open(test_file, 'rb'), delimiter=',', quotechar='"')
with open('month_spell.csv', 'w') as csvoutput:
writer = csv.writer(csvoutput)
for line in csv_file:
event = None
if line['COLLISION_MONTH'] == '01':
event = 'Jan'
elif line['COLLISION_MONTH'] == '02':
event = 'Feb'
elif line['COLLISION_MONTH'] == '03':
event = 'Mar'
elif line['COLLISION_MONTH'] == '04':
event = 'Apr'
elif line['COLLISION_MONTH'] == '05':
event = 'May'
elif line['COLLISION_MONTH'] == '06':
event = 'Jun'
elif line['COLLISION_MONTH'] == '07':
event = 'Jul'
elif line['COLLISION_MONTH'] == '08':
event = 'Aug'
elif line['COLLISION_MONTH'] == '09':
event = 'Sep'
elif line['COLLISION_MONTH'] == '10':
event = 'Oct'
elif line['COLLISION_MONTH'] == '11':
event = 'Nov'
elif line['COLLISION_MONTH'] == '12':
event = 'Dec'
writer.writerow([
event
])