from typing import Union
import pathlib
import csv


def read_csv(filename: Union[pathlib.Path, str]):
    """Read a CSV file.

    **Example**:

    >>> read_csv('/path/to/data.csv')
    [{ 'name': 'foo' }]

    :param filename:
        Path to CSV file.
    :return:
        A Python representation of the CSV document.
    """
    if isinstance(filename, str):
        filename = pathlib.Path(filename)
    with open(filename) as fh:
        fields = fh.readline().replace('"', "").replace("\n", "").split(",")
        reader = csv.DictReader(fh, fieldnames=fields)
        return list(dict(row) for row in reader)