import csv


def get_first_last_onset(csv_file):
    """Gets the first and last onset times."""
    with open(csv_file) as f:
        full_track = list(csv.reader(f))
    first_onset = float(full_track[0][0])
    if first_onset < 0:
        first_onset = abs(first_onset)  # we only store the first onset if it is
                                        # negative (i.e., starts in an upbeat)
    else:
        first_onset = 0
    last_onset = float(full_track[-1][0])
    return first_onset, last_onset