Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import pandas as pd
|
2 |
+
from collections import Counter
|
3 |
+
import re
|
4 |
+
|
5 |
+
def extract_keywords(text):
|
6 |
+
# ํ
์คํธ์์ ์คํ์ด์ค๋ก ๊ตฌ๋ถ๋ ๋จ์ด๋ฅผ ์ถ์ถ
|
7 |
+
keywords = text.split(" ")
|
8 |
+
return keywords
|
9 |
+
|
10 |
+
def process_excel(input_file, output_file):
|
11 |
+
# ์์
ํ์ผ ์ฝ๊ธฐ
|
12 |
+
df = pd.read_excel(input_file)
|
13 |
+
|
14 |
+
# ๊ฒฐ๊ณผ ์ ์ฅ์ ์ํ ๋ฆฌ์คํธ ์ด๊ธฐํ
|
15 |
+
all_keywords = []
|
16 |
+
|
17 |
+
# D4 ์
๋ถํฐ ๋๊น์ง ์ํ๋ช
๋ฐ์ดํฐ๋ฅผ ์ฒ๋ฆฌ
|
18 |
+
for index, row in df.iterrows():
|
19 |
+
product_name = row['์ํ๋ช
(๋งํฌ)'] # '์ํ๋ช
(๋งํฌ)' ์ด์ด ์ ํํ์ง ํ์ธํด์ผ ํฉ๋๋ค
|
20 |
+
if pd.notna(product_name):
|
21 |
+
keywords = extract_keywords(product_name)
|
22 |
+
all_keywords.extend(keywords)
|
23 |
+
|
24 |
+
# ํค์๋ ๋น๋์ ๊ณ์ฐ
|
25 |
+
keyword_counter = Counter(all_keywords)
|
26 |
+
|
27 |
+
# ๊ฒฐ๊ณผ๋ฅผ ๋ฐ์ดํฐํ๋ ์์ผ๋ก ๋ณํ
|
28 |
+
result_df = pd.DataFrame(keyword_counter.items(), columns=['ํค์๋', '๋น๋์'])
|
29 |
+
|
30 |
+
# ๋น๋์ ๊ธฐ์ค์ผ๋ก ๋ด๋ฆผ์ฐจ์ ์ ๋ ฌ
|
31 |
+
result_df = result_df.sort_values(by='๋น๋์', ascending=False)
|
32 |
+
|
33 |
+
# ๊ฒฐ๊ณผ๋ฅผ ์๋ก์ด ์์
ํ์ผ๋ก ์ ์ฅ
|
34 |
+
result_df.to_excel(output_file, index=False)
|
35 |
+
|
36 |
+
if __name__ == "__main__":
|
37 |
+
input_file = "input.xlsx" # ์
๋ ฅ ํ์ผ๋ช
|
38 |
+
output_file = "output.xlsx" # ์ถ๋ ฅ ํ์ผ๋ช
|
39 |
+
|
40 |
+
process_excel(input_file, output_file)
|