The Dutch election council publishes election results in two formats:
- A website Verkiezingsuitslagen where for each election, each municipality has its own page with local results;
- Files in Election Markup Language (EML), published at the national government’s data portal.
Background (in Dutch)
This will produce a csv file containing results per municipality.
Example:
from kiesraad import scrape
scrape.scrape('TK20170315')
df = scrape.parse_downloaded_pages('TK20170315')
If you want to extract seats instead of votes:
df = scrape.parse_downloaded_pages('TK20170315', unit='seats')
This will produce csv files for each municipality, containing results at polling station level. If desired, these can include votes per candidate.
Example:
from pathlib import Path
import pandas as pd
from kiesraad import parse_eml
source = Path('../data/TK2017')
dfs = parse_eml.parse_eml(source)
target = source / 'csv'
target.mkdir(exist_ok=True)
for name, df in dfs.items():
path = target / f'{name}.csv'
df.to_csv(path, index=False)
Please check the results; they are not guaranteed to be accurate.