MRasheq commited on
Commit
7ed8a15
·
1 Parent(s): 24cf4d3

Third commit

Browse files
Files changed (1) hide show
  1. app.py +8 -4
app.py CHANGED
@@ -25,10 +25,14 @@ LOGS_DIR = "training_logs"
25
  def save_uploaded_file(file):
26
  """Save uploaded file and return its path"""
27
  os.makedirs('uploads', exist_ok=True)
28
- file_path = os.path.join('uploads', file.name)
29
- with open(file_path, 'wb') as f:
30
- f.write(file.read())
31
- return file_path
 
 
 
 
32
 
33
  def prepare_training_data(df):
34
  """Convert DataFrame into Q&A format"""
 
25
  def save_uploaded_file(file):
26
  """Save uploaded file and return its path"""
27
  os.makedirs('uploads', exist_ok=True)
28
+ import tempfile
29
+
30
+ # Create a temporary file with .csv extension
31
+ temp = tempfile.NamedTemporaryFile(delete=False, suffix='.csv', dir='uploads')
32
+ temp.write(file)
33
+ temp.close()
34
+
35
+ return temp.name
36
 
37
  def prepare_training_data(df):
38
  """Convert DataFrame into Q&A format"""