Ein modul�bergreifendes CSV-Import-System, das Feldmappings abfragt, erlernt und f�r verschiedene Datenquellen wiederverwendet.
Aktuell gibt es separate CSV-Import-Endpunkte f�r:
Jeder Import hat hardcodierte Feldnamen. Bei neuen Formaten oder Apps muss der Code angepasst werden.
Ein universeller Parser, der:
csv_field_mappings
Flow:
Zielmodul: [Dropdown: Gewicht | Ern�hrung | Aktivit�t | Schlaf | Vitalwerte] Feldmappings: CSV-Spalte "Datum" ? [Dropdown: date | created_at | timestamp | ---] CSV-Spalte "Gewicht" ? [Dropdown: weight | value | ---] CSV-Spalte "Notiz" ? [Dropdown: note | comment | ---] [X] Mapping speichern f�r zuk�nftige Importe
Tabelle: csv_field_mappings
CREATE TABLE csv_field_mappings ( id UUID PRIMARY KEY, profile_id UUID REFERENCES profiles(id), -- NULL = global target_module VARCHAR(50), -- "weight", "nutrition", "activity", etc. source_fingerprint VARCHAR(64), -- SHA256 Hash der Spalten (sortiert) source_name VARCHAR(100), -- z.B. "Withings Export", "MyFitnessPal CSV" field_mappings JSONB, -- {"Datum": "date", "Gewicht (kg)": "weight"} created_at TIMESTAMP DEFAULT NOW() );
Fingerprint-Berechnung:
import hashlib, json columns = sorted(["Datum", "Gewicht (kg)", "Notiz"]) fingerprint = hashlib.sha256(json.dumps(columns).encode()).hexdigest()
POST /api/import/universal
multipart/form-data
{"fingerprint": "abc123", "mapping_id": "uuid", "preview": [...]}
{"fingerprint": "abc123", "columns": ["Datum", ...], "needs_mapping": true}
POST /api/import/universal/map
{"fingerprint": "abc123", "target_module": "weight", "mappings": {...}, "source_name": "..."}
GET /api/import/mappings
DELETE /api/import/mappings/{id}
Jeder Zielmodul definiert erforderliche Felder:
MODULE_SCHEMAS = { "weight": { "required": ["date", "weight"], "optional": ["note"], "target_table": "weight_log" }, "nutrition": { "required": ["date", "kcal"], "optional": ["protein_g", "fat_g", "carbs_g"], "target_table": "nutrition_log" }, # ... }
UniversalCsvImport.jsx
Integration in Module:
csv
chardet
weight
Medium � Nice-to-have f�r v9e/v9f
feature, develop
feature
develop
Duplikat von #21
No dependencies set.
The note is not visible to the blocked user.
Feature Request: Universeller CSV-Parser
Beschreibung
Ein modul�bergreifendes CSV-Import-System, das Feldmappings abfragt, erlernt und f�r verschiedene Datenquellen wiederverwendet.
Motivation
Aktuell gibt es separate CSV-Import-Endpunkte f�r:
Jeder Import hat hardcodierte Feldnamen. Bei neuen Formaten oder Apps muss der Code angepasst werden.
Ziel
Ein universeller Parser, der:
csv_field_mappings)Anforderungen
1. Feldmapping-Assistent (UI)
Flow:
2. Datenbankschema
Tabelle:
csv_field_mappingsFingerprint-Berechnung:
3. API-Endpunkte
POST /api/import/universal
multipart/form-datamit CSV-Datei{"fingerprint": "abc123", "mapping_id": "uuid", "preview": [...]}{"fingerprint": "abc123", "columns": ["Datum", ...], "needs_mapping": true}POST /api/import/universal/map
{"fingerprint": "abc123", "target_module": "weight", "mappings": {...}, "source_name": "..."}GET /api/import/mappings
DELETE /api/import/mappings/{id}
4. Modul-Integration
Jeder Zielmodul definiert erforderliche Felder:
5. UI-Komponente
UniversalCsvImport.jsx
Integration in Module:
Vorteile
Beispiel-Workflow
Technische Details
csvModul (Python stdlib)chardetf�r UTF-8/ISO-8859-1Phasen
Phase 1: MVP
csv_field_mappingsweightPhase 2: Erweitert
Phase 3: Komfort
Priorit�t
Medium � Nice-to-have f�r v9e/v9f
Labels
feature,developDuplikat von #21