Created
October 7, 2020 17:59
-
-
Save matthewbauer/1f98a97d50901dd3f8319e1d3df112c1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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