import csv


def csv_readline_to_list(csv_file):
    """
    Read the CSV content by line.

    Example:
        csv content:
            |name|age|
            | a  |21 |
            | b  |22 |
            | c  |23 |
            | d  |24 |
            | e  |25 |
        ret = csv_readline_to_list("d/demo.csv")
    Return:
        [['name', 'age'], ['a', '21'], ['b', '22'], ['c', '34'], ['d', '24'], ['e', '25']] 
    """
    try:
        with open(csv_file, 'r', encoding="utf-8") as csv_fp:
            reader = csv.reader(csv_fp)
            rows = [row for row in reader]
    except UnicodeDecodeError:
        with open(csv_file, 'r', encoding="gbk") as csv_fp:
            reader = csv.reader(csv_fp)
            rows = [row for row in reader]

    except IOError as ex:
        raise Exception(ex)

    return rows