Created
September 20, 2018 13:44
-
-
Save bjgill/bb4eafbef2833a712b684d74636f00e6 to your computer and use it in GitHub Desktop.
Script for updating the Enfield Green Party voting records
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 | |
"""update_register.py | |
Usage: | |
update_register.py [-h] FILENAME | |
""" | |
from docopt import docopt | |
import openpyxl | |
def main(filename): | |
workbook = openpyxl.load_workbook(filename) | |
worksheet = workbook.active | |
for row in worksheet.rows: | |
[house_number, _, _, first_name, surname, voting_record, *_] = row | |
if first_name.value: | |
print(f"{str(house_number.value)}: {surname.value.upper()}, {first_name.value}") | |
voted = input("Did they vote [(y)es/(n)o]?") | |
if voted and voted in ['yes', 'y']: | |
if voting_record.value: | |
voting_record.value = voting_record.value.rstrip('/') + "/V18" | |
else: | |
voting_record.value = "V18" | |
workbook.save("processed_" + filename) | |
if __name__ == '__main__': | |
arguments = docopt(__doc__) | |
main(arguments['FILENAME']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment