Update app.py
Browse files
app.py
CHANGED
|
@@ -88,6 +88,44 @@ def create_app():
|
|
| 88 |
outputs=[output_df, download_file]
|
| 89 |
)
|
| 90 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 91 |
return demo
|
| 92 |
|
| 93 |
if __name__ == "__main__":
|
|
|
|
| 88 |
outputs=[output_df, download_file]
|
| 89 |
)
|
| 90 |
|
| 91 |
+
###############################
|
| 92 |
+
# ์ฌ๊ธฐ์๋ถํฐ ์๋ก ์ถ๊ฐ๋ ๊ธฐ๋ฅ #
|
| 93 |
+
###############################
|
| 94 |
+
gr.Markdown("## ๊ฐ๋งน์ ๋ช
๊ฒ์ ๊ธฐ๋ฅ(์ถ๊ฐ)")
|
| 95 |
+
|
| 96 |
+
text_input = gr.Textbox(label="๊ฐ๋งน์ ๋ช
์
๋ ฅ")
|
| 97 |
+
text_output = gr.Textbox(label="๊ฒ์ ๊ฒฐ๊ณผ", lines=4)
|
| 98 |
+
|
| 99 |
+
def search_data(file, store_name):
|
| 100 |
+
if not file:
|
| 101 |
+
return "์์
ํ์ผ์ ์
๋ก๋ ํด์ฃผ์ธ์."
|
| 102 |
+
# ์ฌ๊ธฐ์๋ ์ฒซ ํ์ ํค๋๋ก ๊ฐ์ ํฉ๋๋ค (A1=๊ฐ๋งน์ ๋ช
, B1=์ฃผ์, ...)
|
| 103 |
+
df2 = pd.read_excel(file.name)
|
| 104 |
+
# A์ด(์ฒซ ๋ฒ์งธ ์ปฌ๋ผ)์์ store_name๊ณผ ๊ฐ์ ํ์ ์ฐพ์
|
| 105 |
+
row = df2[df2[df2.columns[0]] == store_name]
|
| 106 |
+
if row.empty:
|
| 107 |
+
return "ํด๋น ๊ฐ๋งน์ ๋ช
์ ์ฐพ์ ์ ์์ต๋๋ค."
|
| 108 |
+
# B, C, D ์ด ๋ฐ์ดํฐ ์ถ์ถ
|
| 109 |
+
address = str(row[df2.columns[1]].values[0])
|
| 110 |
+
biz_type = str(row[df2.columns[2]].values[0])
|
| 111 |
+
data_date = str(row[df2.columns[3]].values[0])
|
| 112 |
+
result_text = (
|
| 113 |
+
f"๊ฐ๋งน์ ๋ช
: {store_name}\n"
|
| 114 |
+
f"์ฃผ์: {address}\n"
|
| 115 |
+
f"์
์ข
๋ช
: {biz_type}\n"
|
| 116 |
+
f"๋ฐ์ดํฐ์ผ์: {data_date}"
|
| 117 |
+
)
|
| 118 |
+
return result_text
|
| 119 |
+
|
| 120 |
+
search_button = gr.Button("๊ฐ๋งน์ ๋ช
๊ฒ์")
|
| 121 |
+
|
| 122 |
+
# 'file_input'๊ณผ 'text_input'์ ๋ฐ์์ 'search_data'๋ก ์ฒ๋ฆฌ ํ 'text_output'์ ํ์
|
| 123 |
+
search_button.click(
|
| 124 |
+
fn=search_data,
|
| 125 |
+
inputs=[file_input, text_input],
|
| 126 |
+
outputs=text_output
|
| 127 |
+
)
|
| 128 |
+
|
| 129 |
return demo
|
| 130 |
|
| 131 |
if __name__ == "__main__":
|