Skip to content

Commit

Permalink
add tables
Browse files Browse the repository at this point in the history
  • Loading branch information
wmentrekin committed Oct 27, 2020
1 parent c3e958e commit 6722800
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions Model.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ def visualize(margins):
def write_results():

#Create CSV for States with closest projected margins
closest_margins_fields = ['State', 'Projected Margin', 'Projected Winner']
closest_margins_rows[0] = ['State', 'Projected Margin', 'Projected Winner']
closest_margins_rows = []
for state in State.states:
row = []
Expand All @@ -435,13 +435,9 @@ def write_results():
for row in closest_margins_rows:
row[1] = str(row[1]) + '%'

#First, create the texts of the columns:
cols = ["<td>{0}</td>". format( "</td><td>".join(t) ) for t in closest_margins_rows]

#then use it to join the rows (tr)
rows = "<tr>{0}</tr>".format( "</tr>\n<tr>".join(cols) )

#finaly, inject it into the html...
#Create HTML Table
cols = ["<td>{0}</td>".format( "</td><td>".join(t)) for t in closest_margins_rows]
rows = "<tr>{0}</tr>".format( "</tr>\n<tr>".join(cols))
display = open("tables/closest_margins.html", 'w')
display.write("""<HTML> <body>
<h2>Closest Projected Margins of Victory</h2>
Expand All @@ -453,7 +449,6 @@ def write_results():

with open('results/closest_margins.csv', 'w') as csv_file:
csv_writer = csv.writer(csv_file)
csv_writer.writerow(closest_margins_fields)
csv_writer.writerows(closest_margins_rows)

#Create CSV for most lopsided States
Expand Down

0 comments on commit 6722800

Please sign in to comment.