You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
1006 B

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()