parsers.candidate_column_csv¶
- parsers.candidate_column_csv(cvr_path: str | Path) Dict[str, List]¶
Reads ballot ranking information stored in csv file called “cvr.csv”. Candidate column names. One ballot per row, with ranks given to candidates in cell rows.
Candidate columns are identified by reading a “candidate_codes.csv” file. Columns present in the CVR file that are not listed in the candidate codes are parsed as auxillary ballot information (precinct ID, etc).
- Parameters:
cvr_path (Union[str, pathlib.Path]) – The path to the directory containing the CVR and candidate codes files.
- Raises:
RuntimeError – Error raised if not all parsed rank lists are the same length.
- Returns:
A dictionary of lists containing all columns in the CVR file. Rank columns are combined into per-ballot lists and stored with the key ‘ranks’. A ‘weight’ key and list of 1’s is added to the dictionary if no ‘weight’ column exists. All weights are of type
decimal.Decimal.- Return type:
Dict[str, List]