-
Notifications
You must be signed in to change notification settings - Fork 0
/
budget_percent_increase.py
49 lines (35 loc) · 1.14 KB
/
budget_percent_increase.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
49
#! /usr/bin/env python3
file2000 = open("2000_budget.txt", "rt")
file2004 = open("2004_budget.txt","rt")
# Read the first line (which is the header)
line_00 = file2000.readline()
line_04 = file2004.readline()
# Read the second and third line (which is the first info row)
line_00 = file2000.readline()
line_04 = file2004.readline()
line_00 = file2000.readline()
line_04 = file2004.readline()
print("line_00 is....")
print(line_00)
# Dictionary with the key being the county
# and the value being the percent 2004/2000
percent_increase = {}
while line_00 and line_04:
fields00 = line_00.split("|")
fields04 = line_04.split("|")
print(fields00)
dist00 = fields00[0]
budget00 = int(fields00[1])
dist04 = fields04[0]
budget04 = int(fields04[1])
# check the two districts are the same
if dist00 and dist04 and dist00 == dist04:
percent_increase[dist00] = (budget04/budget00)
# Progress on to the next line
line_00 = file2000.readline()
line_04 = file2004.readline()
# Print
for each in percent_increase:
print(each + "|" + str(percent_increase[each]))
file2000.close()
file2004.close()