Mass Shootings 2015
#!/usr/bin/env python
'''
2015 days with mass shootings. Number is total shot and injured. A . is a day with no mass shootings.
Data is from: http://shootingtracker.com/wiki/Main_Page
Note that shooting tracker considers any shooting incident with 4 or more people shot (not just killed) a "mass shooting
5 5 . 6 . 4 4 4 4 4 5 4 5 5 . . . . 7 4
. . 6 5 . 5 . 4 5 . . 5 . . 4 6 4 7 6 4
. . . . . 5 . 4 . . . . 5 . . 5 . 9 4 6
5 4 7 . . . . 4 5 4 . 5 5 4 4 7 4 4 6 5
7 5 4 . 4 . 7 4 4 . . 5 4 . 5 . 4 . . .
. . . . . 5 . 5 4 . 5 . . . 7 . 4 . . .
5 . 7 4 . . 4 . . 4 . 5 4 . . 4 27 4 4 5
. . 4 5 5 4 . 5 4 4 5 . . 4 . 4 5 5 . 4
4 4 4 5 4 4 4 9 . 4 12 4 7 4 4 4 4 4 6 4
. 4 . 4 4 4 . 4 . . . . 4 5 4 5 4 5 4 4
5 4 5 12 . 4 4 5 4 . 4 . 4 7 5 5 . 4 4 8
4 4 . . . . 4 4 . . 7 4 4 8 . . 4 4 4 4
4 4 . 4 . . . 4 . 5 4 . . 5 4 4 . 4 . 6
. 4 6 4 . 5 5 4 4 10 4 5 . 17 .
'''
import requests
import csv
import StringIO
from datetime import *
from dateutil.relativedelta import *
import sys
s = requests.get("http://shootingtracker.com/tracker/2015CURRENT.csv").text
stream = StringIO.StringIO(s)
reader = csv.DictReader(stream)
totals = {}
for line in reader:
d = datetime.strptime(line["Date"], "%m/%d/%Y")
d = d.date()
totals[d] = int(line["Injured"]) + int(line["Dead"])
current = date(2015,1,1)
today = date(2015, 10, 2) # crude
for d in range(1, 366): # cruder still
if current in totals:
total = totals[current]
else:
total = '.'
sys.stdout.write("{:>2}".format(total))
if d % 20:
sys.stdout.write(" ")
else:
sys.stdout.write("\n")
current = current + relativedelta(days=+1)
if current > today:
break