parsers.rank_column_csv¶
- parsers.rank_column_csv(cvr_path: str | Path) Dict[str, List]¶
Reads ballot ranking information stored in csv format. One ballot per row, with ranking columns appearing in order and named with the word “rank” (e.x. “rank1”, “rank2”, etc)
- Parameters:
cvr_path (Union[str, pathlib.Path]) – The path to the CVR file. If a file called “candidate_codes.csv” exists in the same directory, it will be read and columns named “code” and “candidate” will be used to replace candidate codes with candidate names in the CVR file during readin.
- 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]