import csv


def read_wordlist_data(filepath, comma=False):
    """
    Reads a wordlist in lingpy format and returns an object.

    Parameters
    ----------
    filepath : string
        Path to the wordlist.
    comma : bool
        Whether to use commas instead of tabulations as field separator
        (default: False).

    Returns
    -------
    data : list of dicts
        A list of dictionaries, where each element is a row in the
        original wordlist file.
    """

    # Get the right field delimiter
    delimiter = "\t,"[comma]

    # Collect information in a single data structure, for later processing
    with open(filepath) as handler:
        data = list(csv.DictReader(handler, delimiter=delimiter))

    return data