29 lines
707 B
Python
29 lines
707 B
Python
from .config import config
|
|
from pathlib import Path
|
|
import csv
|
|
|
|
CSV_STYLE = {
|
|
"delimiter": ",",
|
|
"quotechar": '"',
|
|
}
|
|
|
|
def list_month_files(file_schema:str="*_months.csv") -> list[Path]:
|
|
return list(Path(config["datapath"]).glob(file_schema))
|
|
|
|
def extract_month(filename:Path) -> list[dict[str,str]]:
|
|
months = []
|
|
with open(filename, 'r', newline='') as csvfile:
|
|
month_reader = csv.DictReader(csvfile, **CSV_STYLE)
|
|
for month in month_reader:
|
|
months.append(month)
|
|
return months
|
|
|
|
|
|
|
|
def retreive_months():
|
|
month_files = list_month_files()
|
|
months = []
|
|
for file in month_files:
|
|
months += extract_month(file)
|
|
return months
|