Files
reporty/40 fio 02 diagnostika.py
2025-10-20 15:44:37 +02:00

48 lines
1.3 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Diagnostický test: načti Fio CSV a ověř parsování datumu.
Nenačítá se do MySQL pouze vypíše výsledek.
"""
import csv
from datetime import datetime
from pathlib import Path
# ✅ Tvoje cesta k souboru
CSV_PATH = Path(r"u:\Dropbox\!!!Days\Downloads Z230\Vyhledane pohyby (1).csv")
def parse_czech_date(s: str):
"""Očistí řetězec a zkusí dd.mm.yyyy."""
if not s:
return None
s = s.strip().replace("\u00A0", "").replace("\ufeff", "")
try:
return datetime.strptime(s, "%d.%m.%Y").date()
except Exception:
return None
def main():
with open(CSV_PATH, "r", encoding="utf-8-sig", newline="") as f:
reader = csv.DictReader(f, delimiter=";", quotechar='"')
rows = list(reader)
print(f"Načteno {len(rows)} řádků.\n")
print("Ukázka prvních 10 řádků s hodnotou Datum:\n")
for i, row in enumerate(rows[:10], start=1):
raw = row.get("Datum")
parsed = parse_czech_date(raw)
print(f"{i:02d}. raw={repr(raw)} -> parsed={parsed}")
input("\n🔸 Stiskni Enter pro pokračování nebo ukončení... ")
if __name__ == "__main__":
if not CSV_PATH.exists():
raise SystemExit(f"❌ Soubor {CSV_PATH} nenalezen.")
main()