Push
This commit is contained in:
81
Export.py
81
Export.py
@@ -1,11 +1,19 @@
|
||||
import csv
|
||||
|
||||
import numpy as np
|
||||
|
||||
import os
|
||||
import webbrowser
|
||||
from datetime import datetime
|
||||
|
||||
|
||||
class Export:
|
||||
def __init__(self):
|
||||
def __init__(self) -> None:
|
||||
pass
|
||||
|
||||
@staticmethod
|
||||
def matrix_to_csv(dateiname, liste_spaltenbeschriftung, liste_zeilenbeschriftung, Matrix, beschriftung_kopfzeile = ""):
|
||||
def matrix_to_csv(dateiname: str, liste_spaltenbeschriftung: list, liste_zeilenbeschriftung: list, Matrix: np.matrix | sp.Matrix,
|
||||
beschriftung_kopfzeile: object = "") -> None:
|
||||
with open(dateiname, "w", newline="", encoding="utf-8") as csvfile:
|
||||
writer = csv.writer(csvfile, delimiter=";")
|
||||
|
||||
@@ -29,7 +37,7 @@ class Export:
|
||||
writer.writerow(zeile_als_text)
|
||||
|
||||
@staticmethod
|
||||
def ausgleichung_to_datei(dateiname, dict_ausgleichung):
|
||||
def ausgleichung_to_datei(dateiname: str, dict_ausgleichung: dict) -> None:
|
||||
with open(dateiname, "w", newline="", encoding="utf-8") as csvfile:
|
||||
writer = csv.writer(csvfile, delimiter=";")
|
||||
|
||||
@@ -65,4 +73,69 @@ class Export:
|
||||
except Exception:
|
||||
value_text = str(value)
|
||||
|
||||
writer.writerow([key, value_text])
|
||||
writer.writerow([key, value_text])
|
||||
|
||||
def speichere_html_protokoll(metadaten, ergebnisse):
|
||||
# Pfad für den Ordner erstellen
|
||||
ordner = "Protokolle"
|
||||
if not os.path.exists(ordner):
|
||||
os.makedirs(ordner)
|
||||
|
||||
dateiname = f"{ordner}/Protokoll_{metadaten['projekt']}.html"
|
||||
abs_path = os.path.abspath(dateiname)
|
||||
|
||||
# HTML Inhalt zusammenbauen
|
||||
html_content = f"""
|
||||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<style>
|
||||
body {{ font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; margin: 40px; line-height: 1.6; color: #333; }}
|
||||
h1 {{ color: #2c3e50; border-bottom: 2px solid #2c3e50; }}
|
||||
h3 {{ color: #2980b9; margin-top: 30px; }}
|
||||
.metadata {{ background: #f9f9f9; padding: 15px; border-radius: 5px; border-left: 5px solid #2980b9; }}
|
||||
table {{ border-collapse: collapse; width: 100%; margin-top: 10px; }}
|
||||
th, td {{ text-align: left; padding: 8px; border-bottom: 1px solid #ddd; }}
|
||||
tr:nth-child(even) {{ background-color: #f2f2f2; }}
|
||||
th {{ background-color: #2980b9; color: white; }}
|
||||
.footer {{ margin-top: 50px; font-size: 0.8em; color: #7f8c8d; text-align: center; }}
|
||||
</style>
|
||||
<title>Netzprotokoll - {metadaten['projekt']}</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Netzprotokoll: {metadaten['projekt']}</h1>
|
||||
|
||||
<div class="metadata">
|
||||
<p><strong>Bearbeiter:</strong> {metadaten['bearbeiter']}</p>
|
||||
<p><strong>Datum:</strong> {metadaten['datum']}</p>
|
||||
<p><strong>Ausgleichungsmodus:</strong> Methode der kleinsten Quadrate (L2-Norm)</p>
|
||||
</div>
|
||||
|
||||
<h3>1. Globaltest</h3>
|
||||
{ergebnisse['df_globaltest'].to_html(index=False)}
|
||||
|
||||
<h3>2. Redundanzanteile</h3>
|
||||
{ergebnisse['df_redundanz'].to_html(index=False)}
|
||||
|
||||
<h3>3. Standardellipsen</h3>
|
||||
{ergebnisse['df_ellipsen'].to_html(index=False)}
|
||||
|
||||
<h3>3. Konfidenzellipsen</h3>
|
||||
{ergebnisse['df_konfidenzellipsen'].to_html(index=False)}
|
||||
|
||||
<div class="footer">
|
||||
Erstellt automatisch am {datetime.now().strftime('%d.%m.%Y um %H:%M:%S')}
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
"""
|
||||
|
||||
# Datei schreiben
|
||||
with open(dateiname, "w", encoding="utf-8") as f:
|
||||
f.write(html_content)
|
||||
|
||||
print(f"✅ Protokoll wurde gespeichert unter: {abs_path}")
|
||||
|
||||
# Datei automatisch im Standard-Browser öffnen
|
||||
webbrowser.open(f"file://{abs_path}")
|
||||
Reference in New Issue
Block a user