Vikas01 commited on
Commit
52e95bc
·
1 Parent(s): 4daa980

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -3
app.py CHANGED
@@ -58,10 +58,15 @@ if img_file_buffer is not None:
58
  raw_data = {'date': [time.asctime(time.localtime(time.time()))], 'v_number': [text]}
59
  df = pd.DataFrame(raw_data, columns=['date', 'v_number'])
60
 
61
- # check if the csv file exists
62
  file_path = os.path.join("data", "data.csv")
63
- header = not os.path.exists(file_path)
64
- df.to_csv(file_path, mode='a', header=header, index=False)
 
 
 
 
 
65
 
66
  # Print recognized text
67
  st.write("Recognized Text:",text)
 
58
  raw_data = {'date': [time.asctime(time.localtime(time.time()))], 'v_number': [text]}
59
  df = pd.DataFrame(raw_data, columns=['date', 'v_number'])
60
 
61
+ # Check if the CSV file exists
62
  file_path = os.path.join("data", "data.csv")
63
+ if os.path.exists(file_path):
64
+ # Append the data to the existing CSV file
65
+ df.to_csv(file_path, mode='a', header=False, index=False)
66
+ else:
67
+ # Create a new CSV file and write the data
68
+ df.to_csv(file_path, mode='w', index=False)
69
+
70
 
71
  # Print recognized text
72
  st.write("Recognized Text:",text)