Spaces:
Sleeping
Sleeping
File size: 1,776 Bytes
bd6d9a2 98c9fa6 fd99d5c 98c9fa6 fd99d5c 98c9fa6 fd99d5c 98c9fa6 fd99d5c 98c9fa6 fd99d5c 98c9fa6 fd99d5c 98c9fa6 fd99d5c 98c9fa6 fd99d5c 98c9fa6 fd99d5c 98c9fa6 fd99d5c 98c9fa6 fd99d5c | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | import gradio as gr
import main # main.py์ ์์ฑ๋ ์ ์ฒ๋ฆฌ ๋ก์ง ํธ์ถ
import os
import pandas as pd
def process_file(file_path, voucher_number):
if file_path is None:
return None
# ํ์ผ ํ์ฅ์ ํ์ธ
ext = os.path.splitext(file_path)[1].lower()
if ext == ".xlsx":
# ์์
ํ์ผ์ CSV๋ก ๋ณํ
df = pd.read_excel(file_path)
csv_path = file_path.replace(".xlsx", ".csv")
df.to_csv(csv_path, index=False)
input_path = csv_path
else:
# ์ด๋ฏธ CSV ํ์ผ์ด๋ฉด ๊ทธ๋๋ก ์ฌ์ฉ
input_path = file_path
# ๋ฉ์ธ ์ ์ฒ๋ฆฌ ํจ์ ํธ์ถ (์ ํ๋ฒํธ ๋๊ฒจ์ฃผ๊ธฐ)
output_path = main.process_rental_company_with_voucher(input_path, voucher_number)
return output_path
# Gradio ์ธํฐํ์ด์ค ๊ตฌ์ฑ
with gr.Blocks() as demo:
gr.Markdown("# ERP ์๋ ์ ํ ๋ณํ๊ธฐ\n\n์
๋ก๋ํ ํ์ผ๊ณผ ์ ํ๋ฒํธ๋ฅผ ์
๋ ฅํ์ธ์.")
with gr.Row():
file_input = gr.File(
label="๋ ํ๋ฃ ํ์ผ ์
๋ก๋ (CSV ๋๋ Excel)",
file_types=[".csv", ".xlsx"],
type="filepath" # โญ ์ฌ๊ธฐ๊ฐ ์ค์!
)
voucher_input = gr.Textbox(
label="์ ํ๋ฒํธ ์
๋ ฅ",
placeholder="์: 20250427001"
)
with gr.Row():
submit_btn = gr.Button("์ ์ถ")
clear_btn = gr.Button("์ง์ฐ๊ธฐ")
output_file = gr.File(label="์ ์ฒ๋ฆฌ ์๋ฃ ํ์ผ ๋ค์ด๋ก๋")
# ๋ฒํผ ํด๋ฆญ ์ด๋ฒคํธ ์ฐ๊ฒฐ
submit_btn.click(
fn=process_file,
inputs=[file_input, voucher_input],
outputs=output_file
)
clear_btn.click(
fn=lambda: (None, ""),
inputs=[],
outputs=[file_input, voucher_input]
)
demo.launch()
|