|
import gradio as gr |
|
import pandas as pd |
|
from io import StringIO |
|
|
|
def process_csv(file_obj): |
|
|
|
df = pd.read_csv(file_obj) |
|
|
|
|
|
df['age'] = df['age'].apply(lambda x: x * 2) |
|
|
|
|
|
output = StringIO() |
|
df.to_csv(output, index=False) |
|
output.seek(0) |
|
|
|
|
|
return output.getvalue().encode('utf-8') |
|
|
|
|
|
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 return the processed CSV.") |
|
|
|
|
|
iface.launch() |
|
|