import csv


def load_csv(filename, label_col):
    """
    Loads a csv file containin the data, parses it
    and returns numpy arrays the containing the training
    and testing data along with their labels.

    :param filename: the filename
    :return: tuple containing train, test data np arrays and labels
    """

    X_train = []
    X_test = []
    num = 0
    with open(filename,'rt') as f:
        reader = csv.reader(f, delimiter=',')
        for row in reader:
            row1 = [float(item) for item in row if item != '\0']
            last_ele = row1.pop(label_col)
            X_train.append(row1)
            X_test.append(int(last_ele))
            num+=1
            if num > 1000:
                break

    f.close()
    return X_train, X_test