Skip to content

Commit

Permalink
Permet la récupération INAO
Browse files Browse the repository at this point in the history
  • Loading branch information
teymour committed Feb 8, 2023
1 parent 9550fc0 commit 27b6575
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions bin/download_parcellaire.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,24 @@ fi

CVI="$cvi" PRODOUANE_USER="$PRODOUANE_USER" PRODOUANE_PASS="$PRODOUANE_PASS" node puppeteer_scrapping/prodouane_parcellaire.js

if [ ! -f "./documents/parcellaire-${cvi}-parcellaire.html" ]; then
echo "Échec du scraping"
exit 4
if test -f "./documents/parcellaire-${cvi}-parcellaire.html"; then
sed -i '/^<?xml /id' "./documents/parcellaire-${cvi}-accueil.html"
sed -i '/^<?xml /id' "./documents/parcellaire-${cvi}-parcellaire.html"
python3 posttraitement/parcellaire_html_to_csv.py "$cvi" 2>&1
fi

sed -i '/^<?xml /id' "./documents/parcellaire-${cvi}-accueil.html"
sed -i '/^<?xml /id' "./documents/parcellaire-${cvi}-parcellaire.html"

python3 posttraitement/parcellaire_html_to_csv.py "$cvi" 2>&1

if ! test -f "documents/parcellaire-${cvi}.csv" && test -f "$INAO_FILE"; then
echo -n "Origine;CVI Operateur;Siret Operateur;Nom Operateur;Adresse Operateur;CP Operateur;Commune Operateur;Email Operateur;IDU;Commune;Lieu dit;Section;" > "documents/parcellaire-${cvi}.csv"
echo "Numero parcelle;Produit;Cepage;Superficie;Superficie cadastrale;Campagne;Ecart pied;Ecart rang;Mode savoir faire;Statut;Date MaJ" >> "documents/parcellaire-${cvi}.csv"
grep "$cvi" $INAO_FILE | awk -F ';' '{idu=substr($4,1,2)substr($4,4,12); gsub(" ", "0", idu); print "INAO";$17";"$19";"$18";;;;;"idu";"$9";"$10";"$1";"$2";"$26" - "$25";"$28";"$36";"$5";"$35";"$37";"$38";"$33";;"$39}' >> "documents/parcellaire-${cvi}.csv"
fi

#Code transitoire
if ! test -f "$INAO_FILE" && test -f "documents/parcellaire-${cvi}.csv" ; then
if ! test test -f "$INAO_FILE" && test -f "documents/parcellaire-${cvi}.csv" ; then
sed -i 's/^[^;]*;//' "documents/parcellaire-${cvi}.csv"
fi
fi

if ! test -f "documents/parcellaire-${cvi}.csv"; then
echo "Échec du scraping"
exit 4
fi

0 comments on commit 27b6575

Please sign in to comment.