utils.py 411 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
import csv
from os import path

ASSETS_PATH = path.join(path.realpath(__file__), "../assets/")  # noqa: E402


def csv_2_dict_list(fp: str):
    """
    Reads a CSV file (with header row!) and returns it as a list of OrderedDict
    :param fp: csv file path
    :type fp: str
    :return:
    """
    with open(fp, "r") as f:
        reader = csv.DictReader(f, delimiter=",")
        return [r for r in reader]