fix fred helpers

This commit is contained in:
Diogo Sousa
2023-07-25 16:09:16 +01:00
parent 228bbfa2e7
commit 068b472e4d

View File

@@ -1,4 +1,6 @@
import csv
import os
from pathlib import Path
from typing import List, Literal
CPI_COUNTRIES = Literal[
@@ -61,8 +63,10 @@ CPI_FREQUENCY = Literal["monthly", "quarterly", "annual"]
def all_cpi_options(harmonized: bool = False) -> List[dict]:
data = []
current_dir = os.path.dirname(os.path.realpath(__file__))
file = "harmonized_cpi.csv" if harmonized else "cpi.csv"
with open(file, encoding="utf-8") as csv_file_handler:
with open(Path(current_dir, file), encoding="utf-8") as csv_file_handler:
csv_reader = csv.DictReader(csv_file_handler)
for rows in csv_reader:
row = {key.lstrip("\ufeff"): value for key, value in rows.items()}