import csv
import logging
import pprint


def csv_to_list(path):
    """Read csv and return a mongoDB bulk insertable list"""
    with open(path, 'r') as c:
        reader = csv.reader(c)

        reader_rows = [row for row in reader]
        column_names = reader_rows[0]
        logging.info(pprint.pprint(column_names))

        insertable_list = []

        for x in range(len(reader_rows)):
            if x == 0:
                continue
            document = {}
            for y in range(len(reader_rows[x])):
                document[column_names[y]] = reader_rows[x][y]
            insertable_list.append(document)

    return insertable_list