parent
b11d73a67e
commit
2ac4fccbd8
@ -0,0 +1,27 @@
|
|||||||
|
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()
|
@ -0,0 +1,5 @@
|
|||||||
|
|
||||||
|
|
||||||
|
class foo(object):
|
||||||
|
def __init__(self,txt):
|
||||||
|
print(txt)
|
@ -0,0 +1,8 @@
|
|||||||
|
import os
|
||||||
|
import csvlogger as clg
|
||||||
|
import foo
|
||||||
|
|
||||||
|
logfile = clg.csvlogger('test', os.getcwd(), ('x', 'y'))
|
||||||
|
|
||||||
|
logfile.addDatapoint((10,10))
|
||||||
|
|
Loading…
Reference in new issue