Spaces:
Running
Running
Blair Yang
commited on
Commit
•
dfba357
1
Parent(s):
01022c9
test
Browse files
app.py
CHANGED
@@ -15,8 +15,13 @@ def append_to_csv(output_path, row_data, header_names):
|
|
15 |
if os.path.exists(output_path) and os.path.getsize(output_path) > 0:
|
16 |
print(f"Appending to {output_path}")
|
17 |
# File exists and is not empty, append without headers
|
|
|
|
|
18 |
df = pd.DataFrame([row_data])
|
19 |
df.to_csv(output_path, mode='a', header=False, index=False)
|
|
|
|
|
|
|
20 |
else:
|
21 |
print(f"Writing to {output_path}")
|
22 |
# File does not exist or is empty, write with headers
|
|
|
15 |
if os.path.exists(output_path) and os.path.getsize(output_path) > 0:
|
16 |
print(f"Appending to {output_path}")
|
17 |
# File exists and is not empty, append without headers
|
18 |
+
# load first
|
19 |
+
|
20 |
df = pd.DataFrame([row_data])
|
21 |
df.to_csv(output_path, mode='a', header=False, index=False)
|
22 |
+
# check and print
|
23 |
+
with open(output_path, 'r') as f:
|
24 |
+
print(f.read())
|
25 |
else:
|
26 |
print(f"Writing to {output_path}")
|
27 |
# File does not exist or is empty, write with headers
|