Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -7,12 +7,9 @@ import os
|
|
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 =
|
16 |
|
17 |
# ν€μλ μΆμΆ λ° λΉλ κ³μ°
|
18 |
all_keywords = []
|
@@ -31,28 +28,27 @@ def process_excel(file):
|
|
31 |
result_df = pd.DataFrame(keyword_counts.items(), columns=['Keyword', 'Frequency'])
|
32 |
result_df = result_df.sort_values(by='Frequency', ascending=False).reset_index(drop=True)
|
33 |
|
|
|
|
|
|
|
|
|
34 |
# λλ ν 리 μμ± νμΈ λ° νμΌ μ μ₯
|
35 |
output_dir = "output"
|
36 |
if not os.path.exists(output_dir):
|
37 |
os.makedirs(output_dir)
|
38 |
|
39 |
-
|
40 |
-
|
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
|
48 |
|
49 |
# Gradio μΈν°νμ΄μ€ μ μ
|
50 |
iface = gr.Interface(
|
51 |
fn=process_excel,
|
52 |
inputs=gr.File(file_types=[".xlsx"]), # μμ
νμΌλ§ μ
λ‘λν μ μκ² μ€μ
|
53 |
-
outputs=
|
54 |
-
title="Excel
|
55 |
-
description="μμ
νμΌμ
|
56 |
)
|
57 |
|
58 |
if __name__ == "__main__":
|
|
|
7 |
def process_excel(file):
|
8 |
# μμ
νμΌ μ½κΈ°
|
9 |
df = pd.read_excel(file.name)
|
10 |
+
|
|
|
|
|
|
|
11 |
# Dμ΄μ λ°μ΄ν° μΆμΆ
|
12 |
+
product_names = df.iloc[:, 3].dropna() # Dμ΄μ 0λΆν° μμνλ―λ‘ indexλ 3
|
13 |
|
14 |
# ν€μλ μΆμΆ λ° λΉλ κ³μ°
|
15 |
all_keywords = []
|
|
|
28 |
result_df = pd.DataFrame(keyword_counts.items(), columns=['Keyword', 'Frequency'])
|
29 |
result_df = result_df.sort_values(by='Frequency', ascending=False).reset_index(drop=True)
|
30 |
|
31 |
+
# A4, B4λΆν° κ²°κ³Όλ₯Ό μμνλλ‘ λ°μ΄ν°νλ μμ μμ
|
32 |
+
result_df_shifted = pd.DataFrame(index=range(3)) # λΉ λ°μ΄ν°νλ μ μμ± (3μΉΈ μλλ‘ μ΄λ)
|
33 |
+
result_df_shifted = pd.concat([result_df_shifted, result_df]).reset_index(drop=True)
|
34 |
+
|
35 |
# λλ ν 리 μμ± νμΈ λ° νμΌ μ μ₯
|
36 |
output_dir = "output"
|
37 |
if not os.path.exists(output_dir):
|
38 |
os.makedirs(output_dir)
|
39 |
|
40 |
+
output_file = os.path.join(output_dir, "keyword_counts.xlsx")
|
41 |
+
result_df_shifted.to_excel(output_file, index=False, header=False, startrow=3) # 3νμμ μμ
|
|
|
|
|
|
|
|
|
|
|
42 |
|
43 |
+
return output_file
|
44 |
|
45 |
# Gradio μΈν°νμ΄μ€ μ μ
|
46 |
iface = gr.Interface(
|
47 |
fn=process_excel,
|
48 |
inputs=gr.File(file_types=[".xlsx"]), # μμ
νμΌλ§ μ
λ‘λν μ μκ² μ€μ
|
49 |
+
outputs="file",
|
50 |
+
title="Excel Keyword Extractor",
|
51 |
+
description="μμ
νμΌμ Dμ΄μμ ν€μλλ₯Ό μΆμΆνκ³ λΉλλ₯Ό κ³μ°νμ¬ μλ‘μ΄ μμ
νμΌλ‘ μΆλ ₯ν©λλ€."
|
52 |
)
|
53 |
|
54 |
if __name__ == "__main__":
|