Kims12 commited on
Commit
afd67dc
โ€ข
1 Parent(s): 33e3849

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -8
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 = df.iloc[:, 3].dropna() # D์—ด์€ 0๋ถ€ํ„ฐ ์‹œ์ž‘ํ•˜๋ฏ€๋กœ index๋Š” 3
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
- output_file = os.path.join(output_dir, "keyword_counts.xlsx")
37
- result_df.to_excel(output_file, index=False)
 
 
 
 
 
38
 
39
- return output_file
40
 
41
  # Gradio ์ธํ„ฐํŽ˜์ด์Šค ์ •์˜
42
  iface = gr.Interface(
43
  fn=process_excel,
44
  inputs=gr.File(file_types=[".xlsx"]), # ์—‘์…€ ํŒŒ์ผ๋งŒ ์—…๋กœ๋“œํ•  ์ˆ˜ ์žˆ๊ฒŒ ์„ค์ •
45
- outputs="file",
46
- title="Excel Keyword Extractor",
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__":