-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpypoll.py
More file actions
38 lines (29 loc) · 849 Bytes
/
pypoll.py
File metadata and controls
38 lines (29 loc) · 849 Bytes
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
import os
import csv
import collections
#set path to pyboss data
election = os.path.join("election_data_2.csv")
#create variables
totalvotes = 0
candidates = []
votedict = {}
#open csv
with open(election, newline="") as csvfile:
next(csvfile, None)
csvreader = csv.reader(csvfile,delimiter=",")
#find the total number of votes cast
for row in csvreader:
row += 1
print(row)
#create a dictionary that extracts all the candidates
#reader = csv.reader(open(election))
#for row in reader:
# key = row[2]
# if key in votedict:
# pass
# votedict[key] = row[0]
# print(votedict)
#find the total number of votes cast
#create dictionary for voters
#find how many votes each candidate has in loop
#find the percentage of votes each candidate won by dividing candidate votes by