Get candidate data into the right format for the AI tools.
This takes raw CSV data from Democracy Club and outputs it as a JSON file in various formats to be used in the AI tools.
- Clone the repo
git clone https://github.com/FullFact/election-2026-candidate-analysis.git - Go to the new
election-2026-candidate-analysisfolder you have just cloned uv syncto update packagespre-commit installto add pre-commit
To run the code: uv run python src/main.py. The output JSON files will be in the data_outputs folder.
If you can't run this code locally, you can run it in GitHub Codespaces. Go to: https://github.com/codespaces/new - select this repo and your chosen branch.
The current code downloads all election candidate data for 7th March 2026 so you do not have to do it manually.
If you wish to read the CSV data from a file there is an option to do that (use read_csv_data_from_file).
The raw_data folder contains existing raw data from the Democracy Club.
This data from Democracy Club is regularly updated, you can download the latest data from here if you wish: https://candidates.democracyclub.org.uk/data/.
uv run pytest .
- What do we do about duplicate candidates for a given election? There is at least one example of a duplicate candidate in the same election list (looks like they are standing in 2 seats - ID 113862). You might want to deal with this and uncomment the code that checks for this in the
validate_election_datafunction. - Have assumed social media doesn't include Mastodon (though that is available - but so far not included).
- At present it includes candidates for all elections on 7th May (inc local elections) - do we need to remove the local ones?