|
...return (td.days / 7) + 1
f = open(r'd:\iraq.txt')
o = open(r'd:\iraq-reformat.txt','w')
cbyweek = {} # casualties by week dictionary
f.readline() # toss out the header
for line in f:
(trash1,dt,trash2,trash3,trash4,num) = line.split('\t',6)
g = getweek(dt)
if g in cbyweek:
cbyweek[g] += int(num)
else:
cbyweek[g] = int(num)
for key in cbyweek:
print >> o, '%s\t%d' % (key,cbyweek[key])
f...
Tags:
war
politics

http://hwc.livejournal.com/82223.html
(Cached)
0 links
Published: 1 year, 5 months ago (Mon, 04 Feb 2008 09:01:34 PST); 1241 bytes
|