def print_csv(headers, data_list, parse_row_fn):
    """Takes headers, data, and a row parsing function, and prints data
    to the console in a csv format.
    """
    try:
        writer = csv.writer(sys.stdout)
        writer.writerow(headers)
        for data in data_list:
            writer.writerow(parse_row_fn(data))
    except csv.Error as e:
        raise CliException('Error writing CSV: {}'.format(e))
def print_csv ( headers , data_list , parse_row_fn ) : try : writer = csv . writer ( sys . stdout ) writer . writerow ( headers ) for data in data_list : writer . writerow ( parse_row_fn ( data ) ) except csv . Error as e : raise CliException ( 'Error writing CSV: {}' . format ( e ) )
Takes headers, data, and a row parsing function, and prints data
    to the console in a csv format.