import csv


def write_to_csv(lst, fname_out):
    """
        Writes to a csv file containing the output. lst is the list that will be writen
        and must be a list of dictionarys/OrderedDicts

    """
    if len(lst) < 1:
        return None

    fieldnames = lst[0]
    with open(fname_out, 'w', newline='') as ptr:
        od_writer = csv.DictWriter(ptr, fieldnames=fieldnames)
        od_writer.writeheader()
        for i in lst:
            od_writer.writerow(i)