Skip to content

Commit

Permalink
Update script due to codes postaux update
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasG77 committed Mar 12, 2024
1 parent d645424 commit 360b6b2
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions download-codes-postaux-la-poste.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@
# jq -c '.[]' sources/codes-postaux.json sources/codes-postaux-missing.json | jq -s . >| sources/codes-postaux-with-fix.json
# rm "$csv_name"* codes-postaux.csv
# Useful when need to take latest CSV file
wget https://datanova.laposte.fr/data-fair/api/v1/datasets/laposte-hexasmal/metadata-attachments/base-officielle-codes-postaux.csv
sed -i 's/code_commune_insee/codeCommune/g' base-officielle-codes-postaux.csv
sed -i 's/code_postal/codePostal/g' base-officielle-codes-postaux.csv
sed -i 's/libelle_d_acheminement/libelleAcheminement/g' base-officielle-codes-postaux.csv
sed -i 's/nom_de_la_commune/nomCommune/g' base-officielle-codes-postaux.csv
csv2json base-officielle-codes-postaux.csv | jq '[.[] | {"codePostal": .codePostal, "codeCommune": .codeCommune, "libelleAcheminement": .libelleAcheminement, "nomCommune": .nomCommune}]' >| sources/codes-postaux.json
wget https://datanova.laposte.fr/data-fair/api/v1/datasets/laposte-hexasmal/data-files/019HexaSmal.csv
echo '"codeCommune","nomCommune","codePostal","libelleAcheminement","ligne_5"' >| 019HexaSmal_changed_headers.csv
tail -n +2 019HexaSmal.csv >> 019HexaSmal_changed_headers.csv
sed -i 's/;/,/g' 019HexaSmal_changed_headers.csv
csv2json 019HexaSmal_changed_headers.csv | jq '[.[] | {"codePostal": .codePostal, "codeCommune": .codeCommune, "libelleAcheminement": .libelleAcheminement, "nomCommune": .nomCommune}]' >| sources/codes-postaux.json
# To fix missing postal codes
jq -c '.[]' sources/codes-postaux.json sources/codes-postaux-missing.json | jq --slurp '.' >| sources/codes-postaux-with-fix.json

0 comments on commit 360b6b2

Please sign in to comment.