Amirizaniani commited on
Commit
119da3b
1 Parent(s): 097f802

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -2
app.py CHANGED
@@ -147,12 +147,19 @@ def process_inputs(llm, file, relevance, diversity, email):
147
  if file is not None:
148
  # Read questions from the uploaded file
149
  try:
150
- df = pd.read_csv(file.name, encoding='utf-8')
151
  except UnicodeDecodeError:
152
  try:
153
- df = pd.read_csv(file.name, encoding='ISO-8859-1')
154
  except Exception as e:
155
  return f"Failed to read file: {e}"
 
 
 
 
 
 
 
156
  questions_list = df.iloc[:, 0].tolist()
157
  else:
158
  return "No questions provided."
 
147
  if file is not None:
148
  # Read questions from the uploaded file
149
  try:
150
+ df = pd.read_csv(file.name, encoding='utf-8', header=None)
151
  except UnicodeDecodeError:
152
  try:
153
+ df = pd.read_csv(file.name, encoding='ISO-8859-1', header=None)
154
  except Exception as e:
155
  return f"Failed to read file: {e}"
156
+ except pd.errors.ParserError as e:
157
+ return f"Failed to parse CSV file: {e}"
158
+
159
+ # Ensure that there is only one column in the file
160
+ if df.shape[1] != 1:
161
+ return "The uploaded file must contain only one column of questions."
162
+
163
  questions_list = df.iloc[:, 0].tolist()
164
  else:
165
  return "No questions provided."