entropy25 commited on
Commit
bf0aa6a
·
verified ·
1 Parent(s): 79dd66d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -9
app.py CHANGED
@@ -476,7 +476,7 @@ class DataHandler:
476
  """Process uploaded file"""
477
  if not file:
478
  return ""
479
-
480
  content = file.read().decode('utf-8')
481
 
482
  if file.name.endswith('.csv'):
@@ -484,21 +484,25 @@ class DataHandler:
484
  csv_file = io.StringIO(content)
485
  reader = csv.reader(csv_file)
486
  try:
487
- headers = next(reader)
488
- text_idx = next((i for i, h in enumerate(headers) if h.strip().lower() == 'text'), 0)
489
  texts = []
490
  for row in reader:
491
- if len(row) > text_idx and row[text_idx].strip():
492
- text = row[text_idx].strip().strip('"')
493
- texts.append(text)
 
494
  return '\n'.join(texts)
495
  except Exception as e:
496
  lines = content.strip().split('\n')[1:]
497
- return '\n'.join(line.strip().strip('"') for line in lines if line.strip())
498
-
 
 
 
 
 
499
  return content
500
 
501
-
502
  # Main Application
503
  class SentimentApp:
504
  """Main application orchestrator"""
 
476
  """Process uploaded file"""
477
  if not file:
478
  return ""
479
+
480
  content = file.read().decode('utf-8')
481
 
482
  if file.name.endswith('.csv'):
 
484
  csv_file = io.StringIO(content)
485
  reader = csv.reader(csv_file)
486
  try:
487
+ next(reader)
 
488
  texts = []
489
  for row in reader:
490
+ if row and row[0].strip():
491
+ text = row[0].strip().strip('"')
492
+ if text:
493
+ texts.append(text)
494
  return '\n'.join(texts)
495
  except Exception as e:
496
  lines = content.strip().split('\n')[1:]
497
+ texts = []
498
+ for line in lines:
499
+ if line.strip():
500
+ text = line.strip().strip('"')
501
+ if text:
502
+ texts.append(text)
503
+ return '\n'.join(texts)
504
  return content
505
 
 
506
  # Main Application
507
  class SentimentApp:
508
  """Main application orchestrator"""