Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@matthewbauer
Created October 7, 2020 17:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matthewbauer/1f98a97d50901dd3f8319e1d3df112c1 to your computer and use it in GitHub Desktop.
Save matthewbauer/1f98a97d50901dd3f8319e1d3df112c1 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
import urllib.request
urlAbsenteeCounty = 'https://s3.amazonaws.com/dl.ncsbe.gov/ENRS/2020_11_03/absentee_counts_county_20201103.csv'
with urllib.request.urlopen(urlAbsenteeCounty) as response:
data = response.read()
lines = data.decode('utf-8').split("\n")
demTotal = 0
unaTotal = 0
repTotal = 0
for line in lines:
if line and line.split(",")[2] == "DEM":
demTotal += int(line.split(",")[5])
if line and line.split(",")[2] == "UNA":
unaTotal += int(line.split(",")[5])
if line and line.split(",")[2] == "REP":
repTotal += int(line.split(",")[5])
print("Democratic Total is %i" % demTotal)
print("Unaffiliated Total is %i" % unaTotal)
print("Republican Total is %i" % repTotal)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment