Skip to content

Commit

Permalink
Permet l'export de données depuis un fichier INAO
Browse files Browse the repository at this point in the history
  • Loading branch information
teymour committed Feb 8, 2023
1 parent 4667a8b commit 9550fc0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
13 changes: 12 additions & 1 deletion bin/download_parcellaire.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,15 @@ fi
sed -i '/^<?xml /id' "./documents/parcellaire-${cvi}-accueil.html"
sed -i '/^<?xml /id' "./documents/parcellaire-${cvi}-parcellaire.html"

python3 posttraitement/parcellaire_to_csv.py "$cvi" 2>&1
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
sed -i 's/^[^;]*;//' "documents/parcellaire-${cvi}.csv"
fi
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def reference2idu_commune_section_num(reference):
liste_parcellaire = []

headers = [
'CVI Operateur', 'Siret Operateur', 'Nom Operateur', 'Adresse Operateur',
'Origine', 'CVI Operateur', 'Siret Operateur', 'Nom Operateur', 'Adresse Operateur',
'CP Operateur', 'Commune Operateur', 'Email Operateur', 'IDU', 'Commune',
'Lieu dit', 'Section', 'Numero parcelle', 'Produit', 'Cepage',
'Superficie', 'Superficie cadastrale', 'Campagne', 'Ecart pied',
Expand All @@ -54,6 +54,7 @@ def reference2idu_commune_section_num(reference):

soup = BeautifulSoup(html_file, 'lxml', parse_only=tables)
tds = soup.select('td.fdcCoordonneCol2')
parcellaire['Origine'] = 'PRODOUANE'
parcellaire['CVI Operateur'] = tds[0].string

if tds[1].string:
Expand Down

0 comments on commit 9550fc0

Please sign in to comment.