Kims12 commited on
Commit
10af70f
โ€ข
1 Parent(s): dce11ac

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +40 -0
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)