|
import gradio as gr |
|
import pandas as pd |
|
import tempfile |
|
import os |
|
|
|
def process_csv(file_obj): |
|
df = pd.read_csv(file_obj) |
|
df['age'] = df['age'] * 2 |
|
|
|
|
|
with tempfile.NamedTemporaryFile(delete=False, suffix='.csv', mode='w+') as tmp_file: |
|
df.to_csv(tmp_file.name, index=False) |
|
|
|
temp_file_path = tmp_file.name |
|
|
|
|
|
return temp_file_path |
|
|
|
iface = gr.Interface(fn=process_csv, |
|
inputs=gr.File(label="Upload CSV"), |
|
outputs=gr.File(label="Download Processed CSV", type="file"), |
|
description="Upload a CSV with 'name' and 'age' columns. This app will double the 'age' and let you download the processed CSV.") |
|
|
|
iface.launch() |
|
|