from __future__ import annotations import csv from dataclasses import dataclass from pathlib import Path @dataclass(frozen=True) class MeasurementSeries: headers: list[str] rows: list[dict[str, str]] class HeliosImportService: def import_csv(self, path: Path) -> MeasurementSeries: with path.open(newline="", encoding="utf-8-sig") as handle: reader = csv.DictReader(handle) return MeasurementSeries(headers=reader.fieldnames or [], rows=list(reader))