AddAIAvengers commited on
Commit
b273bd6
·
verified ·
1 Parent(s): 7a2bcbd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -5
app.py CHANGED
@@ -4,6 +4,8 @@ import pandas as pd
4
 
5
  def process_csv(df):
6
 
 
 
7
  # Split the 'title' column on ' -' and keep only the first part
8
  df['title'] = df['title'].str.split(' -').str[0]
9
  df = df.rename(columns={'request_text': 'Veta', 'intent_1': 'Intent', 'title': 'ID Odpovedi'})
@@ -18,16 +20,12 @@ def process_csv(df):
18
 
19
 
20
  def process_and_save(file):
 
21
  # Load the CSV file into a DataFrame
22
  df = pd.read_csv(file.name, index_col=False)
23
  df.reset_index(drop=True, inplace=True)
24
-
25
- # Check for commas in any of the columns and filter out those rows
26
- df = df[~df.apply(lambda row: row.astype(str).str.contains(',').any(), axis=1)]
27
-
28
  # Process the DataFrame using your script
29
  processed_df = process_csv(df)
30
-
31
  # Save the processed DataFrame to an Excel file
32
  output_file = 'processed_output.csv'
33
  processed_df.to_csv(output_file, index=False)
 
4
 
5
  def process_csv(df):
6
 
7
+ # Check for commas in any of the columns and filter out those rows
8
+ df = df[~df.apply(lambda row: row.astype(str).str.contains(',').any(), axis=1)]
9
  # Split the 'title' column on ' -' and keep only the first part
10
  df['title'] = df['title'].str.split(' -').str[0]
11
  df = df.rename(columns={'request_text': 'Veta', 'intent_1': 'Intent', 'title': 'ID Odpovedi'})
 
20
 
21
 
22
  def process_and_save(file):
23
+
24
  # Load the CSV file into a DataFrame
25
  df = pd.read_csv(file.name, index_col=False)
26
  df.reset_index(drop=True, inplace=True)
 
 
 
 
27
  # Process the DataFrame using your script
28
  processed_df = process_csv(df)
 
29
  # Save the processed DataFrame to an Excel file
30
  output_file = 'processed_output.csv'
31
  processed_df.to_csv(output_file, index=False)