import csv

class csvlogger(object):
    def __init__(self, filename, filelocation, header):
        self.filename = filename
        self.filelocation = filelocation
        self.header = header
        self.filepath = filelocation + '\\' + filename + '.csv'

        print(self.filepath)

        with open(self.filepath, 'w', newline='' ) as f:
            writer = csv.writer(f, delimiter=',', quotechar='"', quoting=csv.QUOTE_MINIMAL)
            writer.writerow(self.header)
            f.close()

    def addDatapoint(self, datapoint):
        with open(self.filepath, 'a', newline='' ) as f:
            writer = csv.writer(f, delimiter=',', quotechar='"', quoting=csv.QUOTE_MINIMAL)
            writer.writerow(datapoint)
            f.close()

    def addDatapoints(self, datapoints):
        with open(self.filepath, 'a', newline='' ) as f:
            writer = csv.writer(f, delimiter=',', quotechar='"', quoting=csv.QUOTE_MINIMAL)
            writer.writerows(datapoints)
            f.close()