Skip to content

Instantly share code, notes, and snippets.

@mostlygeek
Created October 12, 2023 22:23
Show Gist options
  • Save mostlygeek/a6a21835a3717bec37ae45024f984206 to your computer and use it in GitHub Desktop.
Save mostlygeek/a6a21835a3717bec37ae45024f984206 to your computer and use it in GitHub Desktop.
Makefile for extract BC special needs data
#
# Statistics from data.gov.bc.ca for students with diverse needs
#
# - downloads the csv file
# - uses csvkit to create the extracted data files
#
INPUT = source.csv
OUTPUT_DIR = output
# output files
PROVINCE_DATA = $(OUTPUT_DIR)/province.csv
all: $(PROVINCE_DATA)
$(INPUT):
@curl --silent --output "$(INPUT)" "https://catalogue.data.gov.bc.ca/dataset/1e730ea9-dd19-4c22-aa95-fe644efc7a06/resource/ab33bc93-ca6c-4e87-a89b-43b354ec2648/download/student_headcount_by_diverse_needs-1991_92-to-2022_23.csv"
$(OUTPUT_DIR):
@mkdir -p $(OUTPUT_DIR)
CSVKIT:
@csvcut --version >/dev/null 2>&1 || (echo "csvkit is not installed. Please install it using pip install csvkit" && exit 1)
$(PROVINCE_DATA): CSVKIT $(OUTPUT_DIR) $(INPUT)
csvgrep -c 3 -m "Province-Total" $(INPUT) | csvcut -c 1,8,9,10 > $(PROVINCE_DATA)
clean:
@rm -rf $(OUTPUT_DIR)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment