Pabutools is a Python package providing the all the tools necessary to work with and analyse participatory budgeting elections. It includes the most common participatory budgeting voting rules, many analysis tools, as well as a Pabulib parser.
import csv
path = "test.pb" # set this variable
with open(path, 'r', newline='', encoding="utf-8") as csvfile:
meta = {}
projects = {}
votes = {}
section = ""
header = []
reader = csv.reader(csvfile, delimiter=';')
for row in reader:
if str(row[0]).strip().lower() in ["meta", "projects", "votes"]:
section = str(row[0]).strip().lower()
header = next(reader)
elif section == "meta":
meta[row[0]] = row[1].strip()
elif section == "projects":
projects[row[0]] = {}
for it, key in enumerate(header[1:]):
projects[row[0]][key.strip()] = row[it+1].strip()
elif section == "votes":
votes[row[0]] = {}
for it, key in enumerate(header[1:]):
votes[row[0]][key.strip()] = row[it+1].strip()