mirror of
https://github.com/Alex38Lyon/Synthese-PSM_LARRA.git
synced 2026-06-01 13:59:13 +00:00
update
This commit is contained in:
+1
-1
Submodule Data updated: 60d8447921...a9606748a6
BIN
Binary file not shown.
BIN
Binary file not shown.
+11
-34
@@ -1,13 +1,13 @@
|
||||
*******************************************************************************************
|
||||
* Calcul des statistiques par entrées d'une BD Therion *
|
||||
* Script pythStat par alexandre.pont@yahoo.fr *
|
||||
* Version : 2025.02.07 *
|
||||
* Fichier source : D:/08 GitHub/Synthese-PSM_LARRA/Outputs/database_Synthese-PSM_LARRA.sql*
|
||||
* Dossier destination : D:/08 GitHub/Synthese-PSM_LARRA/Outputs/stat_database_Synthese-PSM_LARRA_2026-01-08/*
|
||||
* Date : 2026-01-08 15:30:41 *
|
||||
* Durée calcul: 01:04:39(s) avec erreur(s): 1 *
|
||||
*******************************************************************************************
|
||||
Développement total centerline: 340754.54 13027.78 10574.75 - - Dev.(m), Dupl.(m), Surf.(m)
|
||||
*************************************************************************************************************************
|
||||
* Calcul des statistiques par entrées d'une BD Therion *
|
||||
* Script pythStat par alexandre.pont@yahoo.fr *
|
||||
* Version : 2026.01.09 *
|
||||
* Fichier source : ~\Synthese-PSM_LARRA\Outputs\database_Synthese-PSM_LARRA.sql *
|
||||
* Dossier destination : ~\Synthese-PSM_LARRA\Outputs\stat_database_Synthese-PSM_LARRA_2026-01-08 *
|
||||
* Date : 2026-01-08 22:56:57 *
|
||||
* Durée calcul: 02(m)23(s) sans erreur *
|
||||
*************************************************************************************************************************
|
||||
**Développement total centerline:** 340754.54 13027.78 10574.75 - - Dev.(m), Dupl.(m), Surf.(m)
|
||||
Attention, 82 station(s) non comptabilisée(s) et raccordée(s)
|
||||
|
||||
Développement total par réseaux
|
||||
@@ -179,34 +179,11 @@ Développement total par réseaux
|
||||
UT683_4758 1 0.00 0.00 0.00 20.00 2 LT346_80 2000.00 LT346_80 2000.00
|
||||
Entrée(s) sans topographie 8 0.00 537.00 0.00 0.00 0 LT345_79 1500.0 SC_3 2037.00
|
||||
|
||||
Développement total topographié par année(s)
|
||||
Développement total topographié par année(s)**
|
||||
Année Dev.(m) Cumul (m) Dupl.(m) Cumul (m) Surf.(m) Cumul (m)
|
||||
1950 1724.74 1724.74 0.00 0.00 0.00 0.00
|
||||
1951 0.00 1724.74 0.00 0.00 0.00 0.00
|
||||
1952 0.00 1724.74 0.00 0.00 0.00 0.00
|
||||
1953 0.00 1724.74 0.00 0.00 0.00 0.00
|
||||
1954 0.00 1724.74 0.00 0.00 0.00 0.00
|
||||
1955 0.00 1724.74 0.00 0.00 0.00 0.00
|
||||
1956 0.00 1724.74 0.00 0.00 0.00 0.00
|
||||
1957 0.00 1724.74 0.00 0.00 0.00 0.00
|
||||
1958 0.00 1724.74 0.00 0.00 0.00 0.00
|
||||
1959 0.00 1724.74 0.00 0.00 0.00 0.00
|
||||
1960 0.00 1724.74 0.00 0.00 0.00 0.00
|
||||
1961 0.00 1724.74 0.00 0.00 0.00 0.00
|
||||
1962 0.00 1724.74 0.00 0.00 0.00 0.00
|
||||
1963 0.00 1724.74 0.00 0.00 0.00 0.00
|
||||
1964 0.00 1724.74 0.00 0.00 0.00 0.00
|
||||
1965 0.00 1724.74 0.00 0.00 0.00 0.00
|
||||
1966 0.00 1724.74 0.00 0.00 0.00 0.00
|
||||
1967 0.00 1724.74 0.00 0.00 0.00 0.00
|
||||
1968 0.00 1724.74 0.00 0.00 0.00 0.00
|
||||
1969 0.00 1724.74 0.00 0.00 0.00 0.00
|
||||
1970 0.00 1724.74 0.00 0.00 0.00 0.00
|
||||
1971 2627.02 4351.76 116.43 116.43 0.00 0.00
|
||||
1972 0.00 4351.76 0.00 116.43 0.00 0.00
|
||||
1973 0.00 4351.76 0.00 116.43 0.00 0.00
|
||||
1974 575.30 4927.06 0.00 116.43 0.00 0.00
|
||||
1975 0.00 4927.06 0.00 116.43 0.00 0.00
|
||||
1976 606.16 5533.22 0.00 116.43 0.00 0.00
|
||||
1977 1411.32 6944.54 0.00 116.43 0.00 0.00
|
||||
1978 2081.24 9025.78 0.00 116.43 0.00 0.00
|
||||
|
||||
|
BIN
Binary file not shown.
+67
-10
@@ -1,12 +1,11 @@
|
||||
*************************************************************************************************************************
|
||||
* Calcul des statistiques par entrées d'une BD Therion *
|
||||
* Script pythStat par alexandre.pont@yahoo.fr *
|
||||
* Version : 2025.02.07 *
|
||||
* Fichier source : ~\Synthese-PSM_LARRA\Outputs\database_Synthese-PSM_LARRA.sql *
|
||||
* Dossier destination : ~\Synthese-PSM_LARRA\Outputs\stat_database_Synthese-PSM_LARRA_2026-01-08 *
|
||||
* Date : 2026-01-08 17:20:49 *
|
||||
* Durée calcul: 02(m)25(s) sans erreur *
|
||||
*************************************************************************************************************************
|
||||
--------------
|
||||
- **Script :** * Calcul des statistiques par entrées d'une BD Therion
|
||||
- **Version :** `* Script pythStat par alexandre.pont@yahoo.fr`
|
||||
- **Fichier source :** `* Version : 2026.01.09`
|
||||
- **Dossier destination :** `* Fichier source : ~\Synthese-PSM_LARRA\Outputs\database_Synthese-PSM_LARRA.sql`
|
||||
- **Date :** `* Dossier destination : ~\Synthese-PSM_LARRA\Outputs\stat_database_Synthese-PSM_LARRA_2026-01-08`
|
||||
- **Durée du calcul :** `* Date : 2026-01-08 22:56:57`
|
||||
- **Durée calcul : ** `02(m)23(s) sans erreur `
|
||||
**Développement total des centerlines (m):** **, Développement:** 340754.54 **, Dupliqué:** 13027.78 **, Surface:** 10574.75
|
||||
!!Attention, 82 station(s) non comptabilisée(s) et raccordée(s)
|
||||
|
||||
@@ -180,7 +179,8 @@
|
||||
| UT683_4758 | 1 | 0.00 | 0.00 | 0.00 | 20.00 | 2 | LT346_80 | 2000.00 | LT346_80 | 2000.00 |
|
||||
| Entrée(s) sans topographie | 8 | 0.00 | 537.00 | 0.00 | 0.00 | 0 | LT345_79 | 1500.0 | SC_3 | 2037.00 |
|
||||
|
||||
--------------**Développement total topographié par année(s)**
|
||||
--------------
|
||||
**Développement total topographié par année(s)**
|
||||
| Année | Dev.(m) | Cumul (m) | Dupl.(m) | Cumul (m) | Surf.(m) | Cumul (m) |
|
||||
| 1950 | 1724.74 | 1724.74 | 0.00 | 0.00 | 0.00 | 0.00 |
|
||||
| 1971 | 2627.02 | 4351.76 | 116.43 | 116.43 | 0.00 | 0.00 |
|
||||
@@ -235,3 +235,60 @@
|
||||
| 2023 | 6343.27 | 327354.72 | 1180.34 | 12377.13 | 79.70 | 10279.50 |
|
||||
| 2024 | 7703.88 | 335058.60 | 547.76 | 12924.89 | 144.72 | 10424.22 |
|
||||
| 2025 | 5695.94 | 340754.54 | 102.89 | 13027.78 | 150.53 | 10574.75 |
|
||||
|
||||
**Développement total topographié par année(s)**
|
||||
| Année | Dev.(m) | Cumul (m) | Dupl.(m) | Cumul (m) | Surf.(m) | Cumul (m) |
|
||||
|---|---|---|---|---|---|---|
|
||||
| 1950 | 1724.74 | 1724.74 | 0.00 | 0.00 | 0.00 | 0.00 |
|
||||
| 1971 | 2627.02 | 4351.76 | 116.43 | 116.43 | 0.00 | 0.00 |
|
||||
| 1974 | 575.30 | 4927.06 | 0.00 | 116.43 | 0.00 | 0.00 |
|
||||
| 1976 | 606.16 | 5533.22 | 0.00 | 116.43 | 0.00 | 0.00 |
|
||||
| 1977 | 1411.32 | 6944.54 | 0.00 | 116.43 | 0.00 | 0.00 |
|
||||
| 1978 | 2081.24 | 9025.78 | 0.00 | 116.43 | 0.00 | 0.00 |
|
||||
| 1979 | 5031.79 | 14057.57 | 64.40 | 180.83 | 0.00 | 0.00 |
|
||||
| 1980 | 940.79 | 14998.36 | 0.00 | 180.83 | 0.00 | 0.00 |
|
||||
| 1981 | 4122.90 | 19121.26 | 0.00 | 180.83 | 0.00 | 0.00 |
|
||||
| 1982 | 6422.46 | 25543.72 | 0.00 | 180.83 | 0.00 | 0.00 |
|
||||
| 1983 | 9040.15 | 34583.87 | 867.57 | 1048.40 | 0.00 | 0.00 |
|
||||
| 1984 | 5635.70 | 40219.57 | 0.00 | 1048.40 | 0.00 | 0.00 |
|
||||
| 1985 | 7594.11 | 47813.68 | 0.00 | 1048.40 | 0.00 | 0.00 |
|
||||
| 1986 | 2747.84 | 50561.52 | 0.00 | 1048.40 | 38.50 | 38.50 |
|
||||
| 1987 | 10648.06 | 61209.58 | 70.66 | 1119.06 | 0.00 | 38.50 |
|
||||
| 1988 | 1310.71 | 62520.29 | 0.00 | 1119.06 | 0.00 | 38.50 |
|
||||
| 1989 | 4088.49 | 66608.78 | 0.00 | 1119.06 | 0.00 | 38.50 |
|
||||
| 1990 | 6920.12 | 73528.90 | 0.00 | 1119.06 | 0.00 | 38.50 |
|
||||
| 1991 | 1164.14 | 74693.04 | 0.00 | 1119.06 | 0.00 | 38.50 |
|
||||
| 1992 | 14467.22 | 89160.26 | 0.00 | 1119.06 | 0.00 | 38.50 |
|
||||
| 1993 | 19380.69 | 108540.95 | 0.00 | 1119.06 | 0.00 | 38.50 |
|
||||
| 1994 | 8749.22 | 117290.17 | 0.00 | 1119.06 | 0.00 | 38.50 |
|
||||
| 1995 | 5661.53 | 122951.70 | 0.00 | 1119.06 | 0.00 | 38.50 |
|
||||
| 1996 | 8964.07 | 131915.77 | 70.08 | 1189.14 | 0.00 | 38.50 |
|
||||
| 1997 | 13193.45 | 145109.22 | 0.00 | 1189.14 | 0.00 | 38.50 |
|
||||
| 1998 | 12640.07 | 157749.29 | 21.10 | 1210.24 | 0.00 | 38.50 |
|
||||
| 1999 | 10657.59 | 168406.88 | 3706.31 | 4916.55 | 137.44 | 175.94 |
|
||||
| 2000 | 6419.46 | 174826.34 | 1214.92 | 6131.47 | 409.80 | 585.74 |
|
||||
| 2001 | 12440.67 | 187267.01 | 596.17 | 6727.64 | 27.39 | 613.13 |
|
||||
| 2002 | 5107.89 | 192374.90 | 247.31 | 6974.95 | 45.44 | 658.57 |
|
||||
| 2003 | 3927.29 | 196302.19 | 0.00 | 6974.95 | 406.12 | 1064.69 |
|
||||
| 2004 | 2645.33 | 198947.52 | 11.06 | 6986.01 | 178.02 | 1242.71 |
|
||||
| 2005 | 2733.71 | 201681.23 | 0.00 | 6986.01 | 405.03 | 1647.74 |
|
||||
| 2006 | 7659.27 | 209340.50 | 80.00 | 7066.01 | 203.64 | 1851.38 |
|
||||
| 2007 | 6496.08 | 215836.58 | 95.38 | 7161.39 | 9.35 | 1860.73 |
|
||||
| 2008 | 4780.88 | 220617.46 | 0.00 | 7161.39 | 158.13 | 2018.86 |
|
||||
| 2009 | 4993.39 | 225610.85 | 5.62 | 7167.01 | 941.69 | 2960.55 |
|
||||
| 2010 | 4700.65 | 230311.50 | 110.00 | 7277.01 | 181.61 | 3142.16 |
|
||||
| 2011 | 5698.22 | 236009.72 | 0.00 | 7277.01 | 309.63 | 3451.79 |
|
||||
| 2012 | 9116.66 | 245126.38 | 0.00 | 7277.01 | 1382.85 | 4834.64 |
|
||||
| 2013 | 9810.78 | 254937.16 | 7.42 | 7284.43 | 527.56 | 5362.20 |
|
||||
| 2014 | 9800.55 | 264737.71 | 150.80 | 7435.23 | 286.91 | 5649.11 |
|
||||
| 2015 | 8429.72 | 273167.43 | 113.45 | 7548.68 | 2288.81 | 7937.92 |
|
||||
| 2016 | 9689.42 | 282856.85 | 885.55 | 8434.23 | 707.05 | 8644.97 |
|
||||
| 2017 | 4858.50 | 287715.35 | 83.46 | 8517.69 | 294.39 | 8939.36 |
|
||||
| 2018 | 7369.21 | 295084.56 | 395.87 | 8913.56 | 496.43 | 9435.79 |
|
||||
| 2019 | 6017.18 | 301101.74 | 289.22 | 9202.78 | 266.20 | 9701.99 |
|
||||
| 2020 | 5050.76 | 306152.50 | 265.07 | 9467.85 | 24.74 | 9726.73 |
|
||||
| 2021 | 7945.59 | 314098.09 | 49.80 | 9517.65 | 315.77 | 10042.50 |
|
||||
| 2022 | 6913.36 | 321011.45 | 1679.14 | 11196.79 | 157.30 | 10199.80 |
|
||||
| 2023 | 6343.27 | 327354.72 | 1180.34 | 12377.13 | 79.70 | 10279.50 |
|
||||
| 2024 | 7703.88 | 335058.60 | 547.76 | 12924.89 | 144.72 | 10424.22 |
|
||||
| 2025 | 5695.94 | 340754.54 | 102.89 | 13027.78 | 150.53 | 10574.75 |
|
||||
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
+167
-41
@@ -24,7 +24,8 @@ from tkinter import filedialog
|
||||
from alive_progress import alive_bar # https://github.com/rsalmei/alive-progress
|
||||
from datetime import datetime
|
||||
|
||||
Version ="2025.02.07"
|
||||
Version ="2026.01.09"
|
||||
|
||||
|
||||
"""#####################################################################################################################################
|
||||
# Fonction pour importer un fichier SQL dans une base de données SQLite #
|
||||
@@ -1280,11 +1281,25 @@ def calcul_stats(output_file):
|
||||
global _largeurColTete
|
||||
|
||||
try:
|
||||
print(f"\033[1;32mPhase 5: Écriture des statistiques dans \033[0m{safe_relpath(output_file)}")
|
||||
print(f"\033[1;32mPhase 5: Écriture des statistiques dans fichier \033[0m{safe_relpath(output_file)}")
|
||||
# Enregistrement des résultats dans un fichier texte
|
||||
output_file_ligne =[]
|
||||
output_file_ligne_md = []
|
||||
output_file_ligne_csv = []
|
||||
|
||||
for i in range(9):
|
||||
output_file_ligne_csv.append(titre[i].ljust(120)+"*\n")
|
||||
|
||||
output_file_ligne_md.extend([
|
||||
f"--------------\n",
|
||||
f"- **Script :** {titre[1].strip()}\n",
|
||||
f"- **Version :** `{titre[2].strip()}`\n",
|
||||
f"- **Fichier source :** `{titre[3].strip()}`\n",
|
||||
f"- **Dossier destination :** `{titre[4].strip()}`\n",
|
||||
f"- **Date :** `{titre[5].strip()}`\n",
|
||||
f"- **Durée du calcul :** `{titre[6].strip()}`\n",
|
||||
f"--------------\n",
|
||||
])
|
||||
|
||||
for i in range(9): output_file_ligne.append(titre[i].ljust(120)+"*\n")
|
||||
|
||||
sql_query1 = ("""
|
||||
Select
|
||||
@@ -1299,14 +1314,15 @@ def calcul_stats(output_file):
|
||||
results = cursor.fetchall()
|
||||
vide ="-".ljust(_largeurCol)
|
||||
|
||||
# output_file_ligne.append(f"Développement total centerline:\t{"{:.2f}".format(results[0][0]).ljust(_largeurCol)}\t{"{:.2f}".format(results[0][1]).ljust(_largeurCol)}\t{vide}\t{vide}\t{vide}\tdev.(m), dupl.(m)\n")
|
||||
#print('Développement total: ' + formatted_row + 'm')
|
||||
# output_file_ligne.append(f"**Développement total centerline:**\t%s\t%s\t%s\t%s\t%s\tDev.(m), Dupl.(m), Surf.(m)\n" %(str("{:.2f}".format(results[0][0]).ljust(_largeurCol)),
|
||||
# str("{:.2f}".format(results[0][1]).ljust(_largeurCol)),
|
||||
# str("{:.2f}".format(results[0][2]).ljust(_largeurCol)),
|
||||
# str(vide), str(vide)))
|
||||
output_file_ligne_csv.append(
|
||||
f"**Développement total centerline:**\t%s\t%s\t%s\t%s\t%s\tDev.(m), Dupl.(m), Surf.(m)\n"
|
||||
%(str("{:.2f}".format(results[0][0]).ljust(_largeurCol)),
|
||||
str("{:.2f}".format(results[0][1]).ljust(_largeurCol)),
|
||||
str("{:.2f}".format(results[0][2]).ljust(_largeurCol)),
|
||||
str(vide),
|
||||
str(vide)))
|
||||
|
||||
output_file_ligne.append(
|
||||
output_file_ligne_md.append(
|
||||
f"**Développement total des centerlines (m):** "
|
||||
f"**, Développement:** {results[0][0]:.2f} "
|
||||
f"**, Dupliqué:** {results[0][1]:.2f} "
|
||||
@@ -1318,31 +1334,52 @@ def calcul_stats(output_file):
|
||||
compteur = int(_compteur[0][0])
|
||||
|
||||
if compteur > 0 : # type: ignore
|
||||
output_file_ligne.append(f"!!Attention, {compteur} station(s) non comptabilisée(s) et raccordée(s)\n")
|
||||
|
||||
output_file_ligne_md.append(f"!!Attention, {compteur} station(s) non comptabilisée(s) et raccordée(s)\n\n")
|
||||
output_file_ligne_csv.append(f"Attention, {compteur} station(s) non comptabilisée(s) et raccordée(s)\n\n")
|
||||
|
||||
results=sql_bilan_reseaux()
|
||||
|
||||
if results[0][0] != None :# type: ignore
|
||||
output_file_ligne.append(f"\n--------------\n")
|
||||
output_file_ligne.append("**Développement total par réseaux**\n")
|
||||
output_file_ligne_md.append(f"--------------\n")
|
||||
output_file_ligne_md.append("**Développement total par réseaux**\n")
|
||||
output_file_ligne_csv.append("Développement total par réseaux\n")
|
||||
for row in results: # type: ignore
|
||||
# formatted_row = '\t'.join(map(str, row))
|
||||
# output_file_ligne.append('\t' + formatted_row + '\n')
|
||||
formatted_row = '\t'.join(map(str, row))
|
||||
output_file_ligne_csv.append('\t' + formatted_row + '\n')
|
||||
|
||||
formatted_row = '| ' + ' | '.join(map(str, row)) + ' |'
|
||||
output_file_ligne.append(formatted_row + '\n')
|
||||
output_file_ligne_md.append(formatted_row + '\n')
|
||||
#print('Développement total: ' + formatted_row + 'm')
|
||||
|
||||
results=sql_bilan_annee()
|
||||
if results[0][0] != None :# type: ignore
|
||||
output_file_ligne.append(f"\n--------------\n")
|
||||
output_file_ligne.append("**Développement total topographié par année(s)**\n")
|
||||
output_file_ligne_md.append(f"\n--------------\n")
|
||||
output_file_ligne_md.append("**Développement total topographié par année(s)**\n")
|
||||
output_file_ligne_csv.append("\nDéveloppement total topographié par année(s)**\n")
|
||||
for row in results: # type: ignore
|
||||
if row[1].strip() != "0.00" or row[3].strip() != "0.00" or row[5].strip() != "0.00" :
|
||||
# Formatage pour Markdown avec alignement simple
|
||||
formatted_row = '\t'.join(map(str, row))
|
||||
output_file_ligne_csv.append('\t' + formatted_row + '\n')
|
||||
|
||||
formatted_row = '| ' + ' | '.join(map(str, row)) + ' |'
|
||||
output_file_ligne.append(formatted_row + '\n')
|
||||
output_file_ligne_md.append(formatted_row + '\n')
|
||||
#print('Développement total: ' + formatted_row + 'm')
|
||||
|
||||
def format_markdown_row(row_data):
|
||||
return '| ' + ' | '.join(f"{str(item):>10}" for item in row_data) + ' |'
|
||||
|
||||
output_file_ligne_md.append("\n**Développement total topographié par année(s)**\n")
|
||||
headers = ["Année", "Dev.(m)", "Cumul (m)", "Dupl.(m)", "Cumul (m)", "Surf.(m)", "Cumul (m)"]
|
||||
|
||||
output_file_ligne_md.append("| " + " | ".join(headers) + " |\n")
|
||||
output_file_ligne_md.append("|" + "|".join(["---"] * len(headers)) + "|\n")
|
||||
|
||||
for row in results[1:]: # type: ignore
|
||||
if row[1].strip() != "0.00" or row[3].strip() != "0.00" or row[5].strip() != "0.00" :
|
||||
formatted_row = [str(v) for v in row]
|
||||
output_file_ligne_md.append("| " + " | ".join(formatted_row) + " |\n")
|
||||
|
||||
|
||||
Rose(output_file_name_rose)
|
||||
|
||||
Shot_lengths_histogram(output_file_name_histo)
|
||||
@@ -1351,7 +1388,7 @@ def calcul_stats(output_file):
|
||||
findetraitement = datetime.now()
|
||||
|
||||
duree = findetraitement - maintenant
|
||||
jours, secondes = divmod(duree.seconds, 86400) # 86400 secondes dans une journée
|
||||
jours, secondes = divmod(duree.seconds, 86400) # 86400 secondes dans une journée
|
||||
heures, secondes = divmod(secondes, 3600) # 3600 secondes dans une heure
|
||||
minutes, secondes = divmod(secondes, 60) # 60 secondes dans une minute
|
||||
if duree.seconds > 3600:
|
||||
@@ -1362,17 +1399,24 @@ def calcul_stats(output_file):
|
||||
duree_formatee = "{:02}(s)".format(secondes)
|
||||
|
||||
if error_count == 0:
|
||||
output_file_ligne[7] = "* Durée calcul: " + duree_formatee + " sans erreur"
|
||||
output_file_ligne[7] = output_file_ligne[7].ljust(120)+"*\n"
|
||||
else :
|
||||
output_file_ligne[7] = "* !!!Durée calcul: " + duree_formatee + " avec erreur(s): " + str(error_count) + "!!!"
|
||||
output_file_ligne[7] = output_file_ligne[7].ljust(120)+"*\n"
|
||||
output_file_ligne_csv[7] = "* Durée calcul: " + duree_formatee + " sans erreur"
|
||||
output_file_ligne_md[7] = "- **Durée calcul : ** `" + duree_formatee + " sans erreur `\n"
|
||||
output_file_ligne_csv[7] = output_file_ligne_csv[7].ljust(120)+"*\n"
|
||||
|
||||
with open(output_file, 'w', encoding='utf-8') as file:
|
||||
file.writelines(output_file_ligne)
|
||||
else :
|
||||
output_file_ligne_csv[7] = "* Durée calcul: " + duree_formatee + " avec erreur(s): " + str(error_count)
|
||||
output_file_ligne_md[7] = "- **Durée calcul : ** `" + duree_formatee + "!! avec erreur(s):`" + str(error_count) + "`\n"
|
||||
output_file_ligne_csv[7] = output_file_ligne_csv[7].ljust(120)+"*\n"
|
||||
|
||||
with open(output_file + ".md", 'w', encoding='utf-8') as file:
|
||||
file.writelines(output_file_ligne_md)
|
||||
|
||||
with open(output_file + ".csv", 'w', encoding='utf-8') as file:
|
||||
file.writelines(output_file_ligne_csv)
|
||||
|
||||
if error_count == 0 :
|
||||
print(f"\033[1;32mPhase 6: Fin de traitement en \033[0m" + duree_formatee + f"\033[1;32m, résultats enregistrés dans \033[0m{safe_relpath(output_file)}")
|
||||
|
||||
else :
|
||||
print(f"\033[1;32mPhase 6: Fin de traitement en \033[0m" + duree_formatee
|
||||
+ f",\033[91m avec \033[0m{error_count}\033[91m erreur(s), \033[1;32mrésultats enregistrés dans \033[0m{safe_relpath(output_file)}")
|
||||
@@ -1380,20 +1424,36 @@ def calcul_stats(output_file):
|
||||
except sqlite3.Error as e:
|
||||
print(f"\033[91mErreur lors de l'exécution des requêtes calcul_stats:\033[0m {e}")
|
||||
error_count += 1
|
||||
output_file_ligne.append(f"Erreur lors de l'exécution des requêtes calcul_stats: {e}\n")
|
||||
with open(output_file, 'w', encoding='utf-8') as file:
|
||||
file.writelines(output_file_ligne)
|
||||
output_file_ligne_md.append(f"!!! Erreur lors de l'exécution des requêtes calcul_stats: {e}\n")
|
||||
output_file_ligne_csv.append(f"Erreur lors de l'exécution des requêtes calcul_stats: {e}\n")
|
||||
|
||||
with open(output_file + ".md", 'w', encoding='utf-8') as file:
|
||||
file.writelines(output_file_ligne_md)
|
||||
|
||||
with open(output_file + ".csv", 'w', encoding='utf-8') as file:
|
||||
file.writelines(output_file_ligne_csv)
|
||||
|
||||
return
|
||||
|
||||
except FileNotFoundError:
|
||||
print(f"\033[91mErreur d'ouverture du fichier: \033[0m{safe_relpath(output_file)} ")
|
||||
error_count += 1
|
||||
|
||||
return
|
||||
|
||||
except Exception as e:
|
||||
print(f"\033[91mErreur lors de l'exécution de calcul_stats:\033[0m {e}")
|
||||
error_count += 1
|
||||
output_file_ligne.append(f"Erreur lors de l'exécution de calcul_stats: {e}\n")
|
||||
with open(output_file, 'w', encoding='utf-8') as file:
|
||||
file.writelines(output_file_ligne)
|
||||
output_file_ligne_md.append(f"!! Erreur lors de l'exécution de calcul_stats: {e}\n")
|
||||
output_file_ligne_csv.append(f"Erreur lors de l'exécution de calcul_stats: {e}\n")
|
||||
|
||||
with open(output_file + ".md", 'w', encoding='utf-8') as file:
|
||||
file.writelines(output_file_ligne_md)
|
||||
|
||||
with open(output_file + ".csv", 'w', encoding='utf-8') as file:
|
||||
file.writelines(output_file_ligne_csv)
|
||||
|
||||
return
|
||||
|
||||
return
|
||||
|
||||
@@ -1445,7 +1505,7 @@ def sql_liste_entree():
|
||||
error_count += 1
|
||||
print(f"\t \033[91mAttention aucune entrée ou point fix comptabilisé\033[0m")
|
||||
else :
|
||||
print(f"\t Table des STATION, entrée et fix nbre: {len(result_ent)}")
|
||||
print(f"\t \033[32mTable des STATION, entrée et fix nbre: \033[0m{len(result_ent)}")
|
||||
|
||||
return result_ent
|
||||
|
||||
@@ -2273,6 +2333,70 @@ def sql_bilan_reseaux():
|
||||
|
||||
return
|
||||
|
||||
|
||||
#####################################################################################################################################
|
||||
# Optimisation, création des indexes #
|
||||
#####################################################################################################################################
|
||||
def sql_optimisation():
|
||||
"""
|
||||
Création des index d’optimisation pour les requêtes de synthèse Therion.
|
||||
Compatible SQLite / PostgreSQL / MySQL.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
cursor : DB cursor
|
||||
Curseur SQL actif
|
||||
verbose : bool
|
||||
Affiche les index créés
|
||||
"""
|
||||
global error_count
|
||||
|
||||
try:
|
||||
|
||||
indexes = [
|
||||
# SERIE
|
||||
("idx_serie_reseau", """
|
||||
CREATE INDEX IF NOT EXISTS idx_serie_reseau
|
||||
ON SERIE (RESEAU_ID)
|
||||
"""),
|
||||
|
||||
("idx_serie_station", """
|
||||
CREATE INDEX IF NOT EXISTS idx_serie_station
|
||||
ON SERIE (STATION_ENT_ID)
|
||||
"""),
|
||||
|
||||
("idx_serie_reseau_station", """
|
||||
CREATE INDEX IF NOT EXISTS idx_serie_reseau_station
|
||||
ON SERIE (RESEAU_ID, STATION_ENT_ID)
|
||||
"""),
|
||||
|
||||
# STATION
|
||||
("idx_station_survey", """
|
||||
CREATE INDEX IF NOT EXISTS idx_station_survey
|
||||
ON STATION (SURVEY_ID)
|
||||
"""),
|
||||
|
||||
# SURVEY
|
||||
("idx_survey_parent", """
|
||||
CREATE INDEX IF NOT EXISTS idx_survey_parent
|
||||
ON SURVEY (PARENT_ID)
|
||||
"""),
|
||||
]
|
||||
|
||||
for name, sql in indexes:
|
||||
cursor.execute(sql)
|
||||
|
||||
|
||||
return
|
||||
|
||||
except Exception as e:
|
||||
print(f"\033[91mErreur lors de l'exécution de la requête (sql_optimisation):\033[0m {e}")
|
||||
error_count += 1
|
||||
return
|
||||
|
||||
|
||||
return
|
||||
|
||||
#####################################################################################################################################
|
||||
# # Clé de tri #
|
||||
#####################################################################################################################################
|
||||
@@ -2716,8 +2840,9 @@ if __name__ == '__main__':
|
||||
|
||||
maintenant = datetime.now()
|
||||
|
||||
parser = argparse.ArgumentParser(description=f"Calcul des statistiques par entrées d'une BD Therion",
|
||||
formatter_class=argparse.RawTextHelpFormatter)
|
||||
parser = argparse.ArgumentParser(
|
||||
description=f"Calcul des statistiques par entrées d'une BD Therion",
|
||||
formatter_class=argparse.RawTextHelpFormatter)
|
||||
parser.print_help = colored_help.__get__(parser)
|
||||
parser.add_argument(
|
||||
'--option',
|
||||
@@ -2732,7 +2857,6 @@ if __name__ == '__main__':
|
||||
parser.add_argument("--file", help="Chemin vers le fichier SQL d'entrée (pas de d'option : fenêtre de choix)")
|
||||
parser.epilog = (f"Commande therion (fichier .thconfig) : export database -o Outputs/database.sql")
|
||||
|
||||
|
||||
# Analyser les arguments de ligne de commande
|
||||
args = parser.parse_args()
|
||||
|
||||
@@ -2771,7 +2895,7 @@ if __name__ == '__main__':
|
||||
|
||||
if not os.path.exists(outputfolder): os.makedirs(outputfolder)
|
||||
|
||||
output_file_name = outputfolder + input_file[:-4]+"_stats.md"
|
||||
output_file_name = outputfolder + input_file[:-4]+"_stats"
|
||||
output_file_name_rose = outputfolder + input_file[:-4]+"_rose.pdf"
|
||||
output_file_name_histo = outputfolder + input_file[:-4]+"_histo.pdf"
|
||||
output_file_name_year = outputfolder + input_file[:-4]+"_year"
|
||||
@@ -2800,6 +2924,8 @@ if __name__ == '__main__':
|
||||
|
||||
construction_tables()
|
||||
|
||||
sql_optimisation()
|
||||
|
||||
calcul_stats(output_file_name)
|
||||
|
||||
elif args.option == "update" :
|
||||
|
||||
Reference in New Issue
Block a user