Implement fin-hub T24-T26: ingest, runway, coupling, RaaS packaging
Add CSV importers, runway calculator, budget alerts, cross-hub coupling emitters, finhub CLI, and raas-mvp-packaging docs with full test coverage.
This commit is contained in:
parent
b6993d4a05
commit
1abbbe85e4
27 changed files with 835 additions and 3 deletions
28
src/fin_hub/ingest/_csv.py
Normal file
28
src/fin_hub/ingest/_csv.py
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
"""Shared CSV helpers."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import csv
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def read_csv_rows(path: Path) -> list[dict[str, str]]:
|
||||
text = path.read_text(encoding="utf-8-sig")
|
||||
reader = csv.DictReader(text.splitlines())
|
||||
return [{k.strip(): (v or "").strip() for k, v in row.items() if k} for row in reader]
|
||||
|
||||
|
||||
def pick(row: dict[str, str], *names: str) -> str:
|
||||
lowered = {k.lower(): v for k, v in row.items()}
|
||||
for name in names:
|
||||
value = lowered.get(name.lower())
|
||||
if value:
|
||||
return value
|
||||
return ""
|
||||
|
||||
|
||||
def parse_amount(value: str) -> float:
|
||||
cleaned = value.replace("€", "").replace("EUR", "").replace(",", ".").strip()
|
||||
if not cleaned:
|
||||
return 0.0
|
||||
return float(cleaned)
|
||||
Loading…
Add table
Add a link
Reference in a new issue