from io import StringIO
import csv


def csv_to_list_from_bin_file(file, header=True):
    """Reads a list from a binary stream

        Args:
            file: The file object
            header (bool): indicates if the file has a header line

        Returns:
            list: the list of rows as a list of cells
        """

    # Read the file decoding with utf-8
    as_str = file.read().decode("utf-8")

    # Create a string IO
    fp = StringIO(as_str)

    # Read the file using the csv reader
    reader = csv.reader(fp, delimiter=',', quotechar='"')

    rows = []

    # Append each row as a list of cells to the rows list
    for row in reader:
        rows.append(row)

    # return the csv file as a list
    if header or len(rows) == 0:
        return rows
    else:
        return rows[1:]