3acd1dd349
We updated the fantoir DB schema. See https://git.alternativebit.fr/NinjaTrappeur/fast-fantoir/src/branch/master for more informations.
29 lines
635 B
Bash
Executable file
29 lines
635 B
Bash
Executable file
#!/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}" <<EOF
|
|
.separator ";"
|
|
.import $1 insee
|
|
EOF
|
|
|
|
sqlite3 "${2}" < "${tmpSql}"
|
|
|
|
|
|
echo "Data imported"
|