kpal002 commited on
Commit
2f367c8
1 Parent(s): 4300eb0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -6
app.py CHANGED
@@ -257,9 +257,11 @@ def process_pdf(uploaded_files, llm_model, n_criteria = num_criteria):
257
  'Title': title,
258
  'Author': author_result
259
  }
260
-
261
  new_row.update({f'score_cr_{i}': score for i, score in enumerate(score_list, 1)})
262
- new_row.update({f'reasoning_cr_{i}': re for i, re in enumerate(reasoning, 1)})
 
 
 
263
 
264
  # Check if the CSV file exists
265
  if os.path.exists(csv_file_path):
@@ -267,11 +269,12 @@ def process_pdf(uploaded_files, llm_model, n_criteria = num_criteria):
267
  df = pd.read_csv(csv_file_path)
268
  else:
269
  # Or create a new DataFrame if the file does not exist
270
- df = pd.DataFrame(columns=['Id'] + [f'score_cr_{i}' for i in range(1, 10)] + [f'reasoning_cr_{i}' for i in range(1, 10)])
271
-
272
- # Append the new data
273
- df = df.append(new_row, ignore_index=True)
274
 
 
 
 
275
  # Save the updated DataFrame back to CSV
276
  df.to_csv(csv_file_path, index=False)
277
 
 
257
  'Title': title,
258
  'Author': author_result
259
  }
 
260
  new_row.update({f'score_cr_{i}': score for i, score in enumerate(score_list, 1)})
261
+ new_row.update({f'reasoning_cr_{i}': reasoning for i, reasoning in enumerate(reasoning, 1)})
262
+
263
+ # Convert new_row dictionary to a DataFrame for easy appending
264
+ new_row_df = pd.DataFrame([new_row])
265
 
266
  # Check if the CSV file exists
267
  if os.path.exists(csv_file_path):
 
269
  df = pd.read_csv(csv_file_path)
270
  else:
271
  # Or create a new DataFrame if the file does not exist
272
+ columns = ['Id', 'Title', 'Author'] + [f'score_cr_{i}' for i in range(1, 10)] + [f'reasoning_cr_{i}' for i in range(1, 10)]
273
+ df = pd.DataFrame(columns=columns)
 
 
274
 
275
+ # Append the new data using pd.concat
276
+ df = pd.concat([df, new_row_df], ignore_index=True)
277
+
278
  # Save the updated DataFrame back to CSV
279
  df.to_csv(csv_file_path, index=False)
280