awacke1 commited on
Commit
19b5c0c
1 Parent(s): 87b4fba

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -7
app.py CHANGED
@@ -40,16 +40,17 @@ def store_message(name: str, message: str, outputfileName: str):
40
  # if file doesnt exist, create it with labels
41
  from os.path import exists
42
  file_exists = exists(savePath)
 
43
  if (file_exists==False):
44
  with open(savePath, "w") as f: #write
45
  f.write(str("time, message, text\n")) # one time only to get column headers for CSV file
46
-
47
- if name and message:
48
- with open(savePath, "a") as csvfile:
49
- writer = csv.DictWriter(csvfile, fieldnames=[ "time", "message", "name", ])
50
- writer.writerow(
51
- {"time": str(datetime.now()), "message": message.strip(), "name": name.strip() }
52
- )
53
  df = pd.read_csv(savePath)
54
  df = df.sort_values(df.columns[0],ascending=False)
55
  return df
 
40
  # if file doesnt exist, create it with labels
41
  from os.path import exists
42
  file_exists = exists(savePath)
43
+
44
  if (file_exists==False):
45
  with open(savePath, "w") as f: #write
46
  f.write(str("time, message, text\n")) # one time only to get column headers for CSV file
47
+ else:
48
+ if name and message:
49
+ with open(savePath, "a") as csvfile:
50
+ writer = csv.DictWriter(csvfile, fieldnames=[ "time", "message", "name", ])
51
+ writer.writerow(
52
+ {"time": str(datetime.now()), "message": message.strip(), "name": name.strip() }
53
+ )
54
  df = pd.read_csv(savePath)
55
  df = df.sort_values(df.columns[0],ascending=False)
56
  return df