Add Panorama MongoDB import + post-import move to Zpracovano

New Panorama/import_to_mongo.py: imports Issues & Deviations XLSX into
MongoDB (db: Panorama, collection: IssuesAndDeviations), all countries,
upsert on record ID with field change history tracking.

Both import scripts (Medidata + Panorama) now move processed files to
Downloads/Zpracovano/ after import to avoid re-processing.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-26 14:11:37 +02:00
parent 08d8cd75ee
commit c46815cea7
16 changed files with 205 additions and 0 deletions
+8
View File
@@ -12,6 +12,7 @@ Použití:
import csv
import re
import shutil
import sys
from datetime import datetime, timezone
from pathlib import Path
@@ -21,6 +22,7 @@ from pymongo import MongoClient, ASCENDING
MONGO_URI = "mongodb://192.168.1.76:27017"
DB_NAME = "edc"
DOWNLOADS_DIR = Path(__file__).parent / "downloads"
PROCESSED_DIR = DOWNLOADS_DIR / "Zpracovano"
COUNTRY_FILTER = "CZE"
@@ -266,6 +268,8 @@ def main():
client.admin.command("ping")
db = client[DB_NAME]
PROCESSED_DIR.mkdir(exist_ok=True)
total = {"inserted": 0, "changed": 0, "unchanged": 0}
for csv_path in paths:
@@ -275,6 +279,10 @@ def main():
for k in total:
total[k] += stats.get(k, 0)
dest = PROCESSED_DIR / csv_path.name
shutil.move(str(csv_path), str(dest))
print(f" -> presunut do Zpracovano/")
client.close()
print(f"\nCelkem: +{total['inserted']} new, ~{total['changed']} changed, ={total['unchanged']} same")