#!/usr/bin/env bash set -eau -o pipefail if [ "$#" -ne 2 ]; then echo "Usage: import-laposte-insee.sh path-to-laposte-insee-CSV fantoir-sqlite-db-path" echo "" echo "ERROR: Missing laposte CSV." echo "You can download it at https://www.data.gouv.fr/fr/datasets/base-officielle-des-codes-postaux/" exit 1 fi tmpDir=$(mktemp -d) clean_tmp () { rm -r "${tmpDir}" } trap clean_tmp EXIT tmpSql="${tmpDir}"/import-laposte-hexasmal.sql echo "Importing laposte/insee hexasmal data into the fantoir db." cat >"${tmpSql}" <