Spaces:
Runtime error
Runtime error
Update app.py
Browse files
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 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
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
|