Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -7,9 +7,12 @@ import os
|
|
7 |
def process_excel(file):
|
8 |
# ์์
ํ์ผ ์ฝ๊ธฐ
|
9 |
df = pd.read_excel(file.name)
|
10 |
-
|
|
|
|
|
|
|
11 |
# D์ด์ ๋ฐ์ดํฐ ์ถ์ถ
|
12 |
-
product_names =
|
13 |
|
14 |
# ํค์๋ ์ถ์ถ ๋ฐ ๋น๋ ๊ณ์ฐ
|
15 |
all_keywords = []
|
@@ -33,18 +36,23 @@ def process_excel(file):
|
|
33 |
if not os.path.exists(output_dir):
|
34 |
os.makedirs(output_dir)
|
35 |
|
36 |
-
|
37 |
-
|
|
|
|
|
|
|
|
|
|
|
38 |
|
39 |
-
return
|
40 |
|
41 |
# Gradio ์ธํฐํ์ด์ค ์ ์
|
42 |
iface = gr.Interface(
|
43 |
fn=process_excel,
|
44 |
inputs=gr.File(file_types=[".xlsx"]), # ์์
ํ์ผ๋ง ์
๋ก๋ํ ์ ์๊ฒ ์ค์
|
45 |
-
outputs="
|
46 |
-
title="Excel Keyword
|
47 |
-
description="์์
ํ์ผ์ D์ด์์ ํค์๋๋ฅผ
|
48 |
)
|
49 |
|
50 |
if __name__ == "__main__":
|
|
|
7 |
def process_excel(file):
|
8 |
# ์์
ํ์ผ ์ฝ๊ธฐ
|
9 |
df = pd.read_excel(file.name)
|
10 |
+
|
11 |
+
# ๋ชจ๋ ์
์ ์๋๋ก 3์นธ์ฉ ์ด๋
|
12 |
+
shifted_df = df.shift(3)
|
13 |
+
|
14 |
# D์ด์ ๋ฐ์ดํฐ ์ถ์ถ
|
15 |
+
product_names = shifted_df.iloc[:, 3].dropna() # D์ด์ 0๋ถํฐ ์์ํ๋ฏ๋ก index๋ 3
|
16 |
|
17 |
# ํค์๋ ์ถ์ถ ๋ฐ ๋น๋ ๊ณ์ฐ
|
18 |
all_keywords = []
|
|
|
36 |
if not os.path.exists(output_dir):
|
37 |
os.makedirs(output_dir)
|
38 |
|
39 |
+
# ๊ฒฐ๊ณผ๋ฅผ ์ ์ฅํ ํ์ผ๋ช
์ค์
|
40 |
+
output_file_shifted = os.path.join(output_dir, "shifted_excel.xlsx")
|
41 |
+
output_file_keywords = os.path.join(output_dir, "keyword_counts.xlsx")
|
42 |
+
|
43 |
+
# ์ด๋๋ ๋ฐ์ดํฐํ๋ ์๊ณผ ํค์๋ ์นด์ดํธ ๊ฒฐ๊ณผ๋ฅผ ๊ฐ๊ฐ ์ ์ฅ
|
44 |
+
shifted_df.to_excel(output_file_shifted, index=False)
|
45 |
+
result_df.to_excel(output_file_keywords, index=False)
|
46 |
|
47 |
+
return [output_file_shifted, output_file_keywords]
|
48 |
|
49 |
# Gradio ์ธํฐํ์ด์ค ์ ์
|
50 |
iface = gr.Interface(
|
51 |
fn=process_excel,
|
52 |
inputs=gr.File(file_types=[".xlsx"]), # ์์
ํ์ผ๋ง ์
๋ก๋ํ ์ ์๊ฒ ์ค์
|
53 |
+
outputs=[gr.File(label="Shifted Excel File"), gr.File(label="Keyword Counts Excel File")],
|
54 |
+
title="Excel Shift Rows and Keyword Extraction",
|
55 |
+
description="์์
ํ์ผ์ ๋ชจ๋ ์
์ ์๋๋ก 3์นธ์ฉ ์ด๋์ํค๊ณ , D์ด์์ ํค์๋๋ฅผ ์ถ์ถํ์ฌ ๋น๋๋ฅผ ๊ณ์ฐํ ํ ๊ฒฐ๊ณผ๋ฅผ ์ ๊ณตํฉ๋๋ค."
|
56 |
)
|
57 |
|
58 |
if __name__ == "__main__":
|