from datetime import datetime


def read_sensor_csv(sensor_file):
    """Read in a sensor .csv file from portal.mkat.karoo.kat.ac.za

       Example of a sensor file entry:
           2020-06-19 10:55:25,nominal,track

       Args:
           sensor_file (str): Filepath to sensor log file.

       Returns:
           times (list): List of datetime objects.
           values (list): List of sensor values.
    """
    values = []
    times = []
    with open(sensor_file, 'r') as f:
        # Skip header:
        f.readline()
        for line in f:
            entry = line.split(',')
            value = entry[-1].strip()
            time = datetime.strptime(entry[0],  '%Y-%m-%d %H:%M:%S')
            values.append(value)
            times.append(time)
    return(values, times)