mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-30 13:10:47 +00:00
load historic epc from csv 🟢
This commit is contained in:
parent
74b7b87de6
commit
32bf1cc98d
1 changed files with 14 additions and 1 deletions
|
|
@ -1,5 +1,18 @@
|
||||||
|
import csv
|
||||||
|
|
||||||
from datatypes.epc.schema.historic_epc import HistoricEpc
|
from datatypes.epc.schema.historic_epc import HistoricEpc
|
||||||
|
|
||||||
|
|
||||||
|
def _normalise(value: str | None) -> str:
|
||||||
|
if value is None:
|
||||||
|
return ""
|
||||||
|
return value.replace("\xa0", " ")
|
||||||
|
|
||||||
|
|
||||||
def read_historic_epc_csv(path: str) -> list[HistoricEpc]:
|
def read_historic_epc_csv(path: str) -> list[HistoricEpc]:
|
||||||
raise NotImplementedError("read_historic_epc_csv not implemented yet")
|
with open(path, newline="", encoding="utf-8") as f:
|
||||||
|
reader = csv.DictReader(f)
|
||||||
|
return [
|
||||||
|
HistoricEpc(**{k.lower(): _normalise(v) for k, v in row.items()})
|
||||||
|
for row in reader
|
||||||
|
]
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue