Download app.py from testrro/TCC: direct link, hf CLI and curl.
- Browser
- Download file 1.42 kB
-
https://huggingface.co/spaces/testrro/TCC/resolve/main/app.py
- Command line
-
hf download hf://spaces/testrro/TCC/app.py
-
curl -L -o app.py https://huggingface.co/spaces/testrro/TCC/resolve/main/app.py
1.42 kB
| # app.py | |
| # বাংলা মন্তব্য সহ Hugging Face Space deploy-ready কোড | |
| import gradio as gr | |
| import pandas as pd | |
| import io | |
| # ----------------------------- | |
| # Text → CSV Function | |
| # ----------------------------- | |
| def text_to_csv(text_data): | |
| try: | |
| lines = text_data.strip().split("\n") | |
| df = pd.DataFrame(lines, columns=["value"]) | |
| csv_buffer = io.StringIO() | |
| df.to_csv(csv_buffer, index=False) | |
| csv_content = csv_buffer.getvalue() | |
| return df.head(), csv_content | |
| except: | |
| return None, "❌ Error converting text to CSV" | |
| # ----------------------------- | |
| # Gradio UI | |
| # ----------------------------- | |
| with gr.Blocks(theme=gr.themes.Monochrome()) as demo2: | |
| gr.Markdown("## 📄 Text → CSV Converter\nবাংলায় সহজ UI, Dark Mode") | |
| text_input = gr.Textbox(label="Paste Your Sequential Data", lines=10, placeholder="Example:\n1.23\n2.45\n1.10") | |
| preview = gr.Dataframe(label="CSV Preview") | |
| download = gr.File(label="Download CSV") | |
| def process(text): | |
| df, csv_content = text_to_csv(text) | |
| if df is not None: | |
| with open("output.csv", "w") as f: | |
| f.write(csv_content) | |
| return df, "output.csv" | |
| else: | |
| return None, None | |
| text_input.change(fn=process, inputs=text_input, outputs=[preview, download]) | |
| demo2.launch() | |