This repository helps you calculate election winners from a Microsoft Forms CSV file.
It supports two methods:
- IRV (Instant Runoff Voting)
- Condorcet (sequential Condorcet with ranked-pairs fallback)
You do not need to understand the code to use it.
Before you run the script, make sure you have:
- Python installed on your computer.
- A Microsoft Forms results file exported as
.csv. - This project folder downloaded
-
Open a Terminal window.
-
Run:
python Election.py
-
Answer the prompts shown in the terminal.
Enter the full path to your election CSV file.
Example:
C:\Users\YourName\Desktop\election_results.csv
Enter positions in this format:
PositionName,NumberOfWinners;PositionName,NumberOfWinners;
Example:
Co-President,2;Treasurer,1;Secretary,1;Public Relations,1;
- Enter
Ifor IRV - Enter
Cfor Condorcet
If one candidate wins multiple positions, the script will ask which position they should keep. It then recalculates the other position without that candidate.
The script prints each position and its final winner(s).
Example:
The winner(s) of Treasurer is/are: Charan Polisetty
Uses elimination rounds based on first-choice votes.
Compares candidates head-to-head and prefers candidates who perform best in pairwise matchups.
If you are unsure of which one to use, default to Condorcet. It is typically regarded as the best method for electing the socially optimal winner.
here is a great article on why (basically, it is kind of hard to complain about the winner of an election when they have beat every other candidate in a 1v1 matchup)
The only reasons for using IRV over Condorcet are if you want to avoid the potential ambiguity of a Condorcet cycle (although the script handles those for you) or if you don't want to have to explain Condorcet to your constituents because you/they are more familiar with IRV. Or maybe you just don't want to use an election method named after an 18th century French dude.
- Wrong CSV path: make sure the file exists and ends in
.csv. - Wrong position format: include commas and semicolons exactly.
- Position name mismatch: names should match CSV column headers.
Election.py: main script you runInstantRunoffVoting.py: IRV logicCondorcetVoting.py: Condorcet logicPosition.py,Candidate.py: election data modelstests/test_election.py: automated tests
- Blank ranking entries are ignored.
- Rankings in each CSV cell should be separated by semicolons.