Spaces:
Sleeping
Sleeping
added data file
Browse files- data_capture.py +4 -1
data_capture.py
CHANGED
|
@@ -39,9 +39,12 @@ def update_csv(data, csv_filename= '/home/runner/work/air-quality/air-quality/ai
|
|
| 39 |
try:
|
| 40 |
os.makedirs(os.path.dirname(csv_filename), exist_ok=True)
|
| 41 |
|
|
|
|
|
|
|
| 42 |
with open(csv_filename, 'a', newline='') as csvfile:
|
| 43 |
csv_writer = csv.writer(csvfile)
|
| 44 |
-
|
|
|
|
| 45 |
csv_writer.writerow(header)
|
| 46 |
csv_writer.writerow(row)
|
| 47 |
print("Data successfully added to CSV.")
|
|
|
|
| 39 |
try:
|
| 40 |
os.makedirs(os.path.dirname(csv_filename), exist_ok=True)
|
| 41 |
|
| 42 |
+
file_exists = os.path.isfile(csv_filename) and os.path.getsize(csv_filename) >0
|
| 43 |
+
|
| 44 |
with open(csv_filename, 'a', newline='') as csvfile:
|
| 45 |
csv_writer = csv.writer(csvfile)
|
| 46 |
+
|
| 47 |
+
if not file_exists:
|
| 48 |
csv_writer.writerow(header)
|
| 49 |
csv_writer.writerow(row)
|
| 50 |
print("Data successfully added to CSV.")
|