From d1f52a5e7ac2dd62c6348f17b02ccf324456c9da Mon Sep 17 00:00:00 2001 From: Guilhem Moulin Date: Thu, 20 Jun 2024 17:32:34 +0200 Subject: Add script to download administrative codes from SCB. Unfortunately SCB doesn't provide CSV files, so we download their xls file and produce our own CSV files. We also add a conversion tool to turn these CSV files into a (single, compact) JSON file to be served via HTTP. --- administrative-codes/Makefile | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 administrative-codes/Makefile (limited to 'administrative-codes/Makefile') diff --git a/administrative-codes/Makefile b/administrative-codes/Makefile new file mode 100644 index 0000000..c0008bc --- /dev/null +++ b/administrative-codes/Makefile @@ -0,0 +1,19 @@ +OUT = administrative-codes +CSV_SOURCES = counties.csv municipalities.csv +GENERATED_FILES = $(addsuffix .json,$(OUT)) $(addsuffix .json.br,$(OUT)) +all: $(GENERATED_FILES) + +$(CSV_SOURCES): %.csv: + ./update + +%.json: $(CSV_SOURCES) + ./csv2json $^ >$@ + +# XXX The brotli(1) executable doesn't support mode=MODE_TEXT +%.json.br: %.json + brotli --best --keep --output=$@ -- $^ + +clean: + rm -f -- $(GENERATED_FILES) + +.PHONY: update clean -- cgit v1.2.3