import csv


def get_data_X_y(data_dir, X=[], y=[]):
    """Read the log file and turn it into X/y pairs."""
    with open(data_dir + 'driving_log.csv') as fin:
        next(fin)
        log = list(csv.reader(fin))

    for row in log:
        if float(row[6]) < 20: continue  # throw away low-speed samples
        X += [row[0].strip(), row[1].strip(), row[2].strip()]       #using center, left and right images
        y += [float(row[3]), float(row[3]) + 0.3, float(row[3]) - 0.3]      #add a small angle to the left camera and subtract a small angle from the right camera

    return X, y