From e08308377c8360864f864bec392f9ff77a11dadd Mon Sep 17 00:00:00 2001 From: Matt Way Date: Thu, 15 Aug 2024 16:48:17 +1000 Subject: [PATCH] Create script to split council_names.json into multiple config.json files in spl-data repo --- copy-config.sh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 copy-config.sh diff --git a/copy-config.sh b/copy-config.sh new file mode 100644 index 0000000..eb12d8f --- /dev/null +++ b/copy-config.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +# Splits council_names.json into separate config.json files for the spl-data repo. + +# This script uses the jq command, make sure it is installed before running this script. + +data_path="$1" + +if test -d "$data_path"; then + jq -c '.[] | .' ./council_names.json | while IFS=' ' read -r council_block; do + slug=$(echo "$council_block" | jq -r '.slug') + if ! test -d "$data_path"/"$slug"; then + mkdir "$data_path"/"$slug" + fi + echo "$council_block" | jq > "$data_path"/"$slug"/config.json + done +else + echo "Could not find $data_path" +fi