Package: vote-extractor
Vote ExtractorSimple python cli to extract voting results from PDFs published by theswiss parliament.InstallationDependenciesMake sure to have the following dependencies installed:Python 3.10 or laterpippipxGhostscript (Windows)Window Setup (Tested on Windows 11)1. Install python & pipOpen the "Marketplace" and search for python. Install it.
Alternatively, download and instal pythonhereOpen a terminal:Start > Type "cmd" > start "Command Prompt"Inside the terminal, typepython --versionand press "Enter".
If you see something like this, python was succesfully installed:\> python --version
Python 3.11.6Also check ifpipwas installed by typingpip --version. If you see something like this you're good:\> pip --version
pip 23.2.1 from C:\... (python 3..11)2. Install pipxInside the terminal, first typepython -m pip install --user pipxConfirm with enter and wait for the command to complete.
Then type:python -m pipx ensurepathAgain, confirm with enter and wait for completion.
Open a new terminal (Start > Type "cmd" > start "Command Prompt") and typepipx --versionto verify if the installation was succesful:\> pipx --version
1.2.13. Install GhostscriptDownload and install Ghostscript fromhere.Now you need to add two environment variables for Ghostscript to your PATH:Press STARTType "Environment Variables" (Umgebungsvariablen?) and look for the option "Edit the system environment variables" (Umgebungsvariablen bearbeiten?)A dialog opens. Double click "Path" in the top panel.Add two new entries to the list, one for thebinand one for thelibdirectory of the just installed Ghostscript dependency. For the paths to the to folders looked like this (might be slightly different on your machine):C:\Program Files\gs10.02.1\bin
C:\Program Files\gs10.02.1\libConfirm and close all dialogs.Ghostscript should be setup correctly.4. Install the App!Now that all dependencies are installed, we can install thevote-extractorusingpipx:In a new terminal, type:\> pipx install vote-extractorOpen a new terminal and typeextract-votes --help. If you see the following output, everything is set up correctly:\> extract-votes --help
usage: extract-votes [-h] [-x] [-c] [-n NAME] [-d DIRECTORY] pdf_url

positional arguments:
  pdf_url               Url to the pdf to extract votes from.

options:
  -h, --help            show this help message and exit
  -x, --excel           Store extracted votes as excel file.
  -c, --csv             Store extracted votes CSV file.
  -n NAME, --name NAME  Name of the generated file(s). Defaults to the input PDF name.
  -d DIRECTORY, --directory DIRECTORY
                        Name of the directory where the generated PDFs are stored. Defaults to `./out.`UsageTo see an overview of what you can do, type:extract-votes --helpTo extract the votes from the following link:https://www.parlament.ch/poly/AbstimmungSR/51/out/Abstimmung_51_6126.pdf...and extract to both an excel file and a csv file named "my-test" inside the folder "my-output-folder", use the following command:extract-votes--csv--excel--directory="my-output-folder"--name="my-test"https://www.parlament.ch/poly/AbstimmungSR/51/out/Abstimmung_51_6126.pdfAfter that, you will see the following files:my-output-folder
├── my-test.csv
└── my-test.xlsxIf you omit the--directoryand--namearguments, the result would be different:extract-votes--csv--excelhttps://www.parlament.ch/poly/AbstimmungSR/51/out/Abstimmung_51_6126.pdfThe resulting files would be:out
├── Abstimmung_51_6126.csv
└── Abstimmung_51_6126.xlsx