-
Notifications
You must be signed in to change notification settings - Fork 0
/
ccvaClasses.py
39 lines (36 loc) · 1.25 KB
/
ccvaClasses.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import csv
import time
curDT = (str(round(time.time_ns())))
curfile = "./data/datafile"+curDT+".csv"
class CurCSV:
def __init__(self,file,data=str):
self.file = file
self.data = data
try:
with open(self.file, 'x') as f:
pass
with open(self.file, "a") as CSVfile:
writer = csv.writer(CSVfile)
writer.writerow(['Time','Subject','Body','Notes'])
except:
pass
def __str__(self):
return "File is" + self.file
def readFile(self):
print("\nFile Contents:\n-----Start of File-----")
with open(self.file, "r+") as CSVfile:
reader = csv.reader(CSVfile)
for row in reader:
print(', '.join(row))
print("-----End of File----\n")
def printCurFile(self):
print("File accessed at " + self.file)
return self.file
def writeFile(self, time, subj, body, notes):
global timeStepper
if self.data == None:
print("No data provided.")
elif self.data == str:
with open(self.file, "a") as CSVfile:
writer = csv.writer(CSVfile)
writer.writerow([time,subj,body,notes])