Vikas01 commited on
Commit
eb8d222
1 Parent(s): d19f7f6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -10
app.py CHANGED
@@ -68,17 +68,9 @@ if img_file_buffer is not None:
68
  # Check if the CSV file exists
69
  file_path = os.path.join("data", "data.csv")
70
  if os.path.exists(file_path):
71
- try:
72
- # Append new data to existing CSV file
73
- existing_df = pd.read_csv(file_path)
74
- updated_df = pd.concat([existing_df, df], ignore_index=True)
75
- updated_df.to_csv(file_path, index=False)
76
- except pd.errors.EmptyDataError:
77
- # If the file is empty, write the new data to it
78
- df.to_csv(file_path, index=False)
79
  else:
80
- # Create new CSV file with data
81
- df.to_csv(file_path, index=False)
82
 
83
  # Print some debug information
84
  st.write("CSV File Path:", file_path)
 
68
  # Check if the CSV file exists
69
  file_path = os.path.join("data", "data.csv")
70
  if os.path.exists(file_path):
71
+ df.to_csv(file_path, mode='a', header=False, index=False) # Append to existing file
 
 
 
 
 
 
 
72
  else:
73
+ df.to_csv(file_path, index=False) # Create new file
 
74
 
75
  # Print some debug information
76
  st.write("CSV File Path:", file_path)