Imsachinsingh00 commited on
Commit
3b0c7e4
·
verified ·
1 Parent(s): fee7fa9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -3,12 +3,12 @@ import pandas as pd
3
  from io import StringIO
4
 
5
  # Function to manipulate CSV based on instruction
6
- def manipulate_csv(file, instruction):
7
- if file is None:
8
  return "Please upload a CSV file", None
9
 
10
  # Read the CSV file
11
- original_df = pd.read_csv(file)
12
  manipulated_df = original_df.copy()
13
 
14
  # Process instruction (basic examples)
@@ -30,10 +30,11 @@ def manipulate_csv(file, instruction):
30
  # Return dataframes as HTML tables
31
  return original_df.to_html(index=False), manipulated_df.to_html(index=False)
32
 
 
33
  # Gradio Interface
34
  with gr.Blocks() as demo:
35
  gr.Markdown("# CSV Manipulation Tool")
36
- file_input = gr.File(label="Upload CSV File", type="file")
37
  instruction_input = gr.Textbox(label="Instruction (e.g., 'add column new_column')")
38
  original_output = gr.HTML(label="Original CSV Data")
39
  manipulated_output = gr.HTML(label="Manipulated CSV Data")
 
3
  from io import StringIO
4
 
5
  # Function to manipulate CSV based on instruction
6
+ def manipulate_csv(file_path, instruction):
7
+ if file_path is None:
8
  return "Please upload a CSV file", None
9
 
10
  # Read the CSV file
11
+ original_df = pd.read_csv(file_path)
12
  manipulated_df = original_df.copy()
13
 
14
  # Process instruction (basic examples)
 
30
  # Return dataframes as HTML tables
31
  return original_df.to_html(index=False), manipulated_df.to_html(index=False)
32
 
33
+
34
  # Gradio Interface
35
  with gr.Blocks() as demo:
36
  gr.Markdown("# CSV Manipulation Tool")
37
+ file_input = gr.File(label="Upload CSV File", type="filepath")
38
  instruction_input = gr.Textbox(label="Instruction (e.g., 'add column new_column')")
39
  original_output = gr.HTML(label="Original CSV Data")
40
  manipulated_output = gr.HTML(label="Manipulated CSV Data")