import csv


def parse_csv(csv_file):
    """Parses an individual CSV file into a set of data points

    Args:
        csv_file (File): a csv file

    Returns:
        List[List[int,int,float]]: A list of data points. 
                                   Each data points consist of 
                                   0: 1 if is a transmission, 
                                   1: 1 if is a retransmission, 
                                   2: time  in seconds
    """
    data_points = []
    csv_reader = csv.reader(csv_file, delimiter=',')
    line_count = 0
    previous_bytes = 0
    start_time = None
    for row in csv_reader:
        if line_count == 0:
            pass
        else:
            if "130.215.28." in row[4]:
                if start_time == None:
                    start_time = sum(x * float(t) for x, t in zip([3600, 60, 1], row[11][12:30].split(":")))
                    data_points.append([0,0,0])
                elif int(row[8]) > previous_bytes:
                    data_points.append([1,0,sum(x * float(t) for x, t in zip([3600, 60, 1], row[11][12:30].split(":"))) - start_time])
                    previous_bytes = int(row[8])
                elif int(row[8]) <= previous_bytes and int(row[8]) > 10:
                    data_points.append([0,1,sum(x * float(t) for x, t in zip([3600, 60, 1], row[11][12:30].split(":"))) - start_time])
        line_count += 1
    return data_points