awacke1 commited on
Commit
bbb5c60
1 Parent(s): 004c842

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -0
app.py CHANGED
@@ -36,6 +36,12 @@ def SaveResult(text, outputfileName):
36
  def store_message(name: str, message: str, outputfileName: str):
37
  basedir = os.path.dirname(__file__)
38
  savePath = outputfileName
 
 
 
 
 
 
39
  if name and message:
40
  with open(savePath, "a") as csvfile:
41
  writer = csv.DictWriter(csvfile, fieldnames=[ "time", "message", "name", ])
 
36
  def store_message(name: str, message: str, outputfileName: str):
37
  basedir = os.path.dirname(__file__)
38
  savePath = outputfileName
39
+
40
+ file_exists = exists(savePath)
41
+ if (file_exists==False):
42
+ with open(outputfileName, "w") as f: #write
43
+ f.write(str("time, message, text\n")) # one time only to get column headers for CSV file
44
+
45
  if name and message:
46
  with open(savePath, "a") as csvfile:
47
  writer = csv.DictWriter(csvfile, fieldnames=[ "time", "message", "name", ])