My (very rushed) code is available in the grecCleaner.py file.
Example data is available in the grec.csv file, taken from Scotland's Census 2022.
The grecRequiredOutput.csv file is an example of the layout of the output file.
Data and project supplied by Grampian Regional Equality Council.