SG34 commited on
Commit
071e9da
·
verified ·
1 Parent(s): d5e70b6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -7
app.py CHANGED
@@ -8,13 +8,20 @@ def extract_keywords(file):
8
  # 엑셀 파일 읽기
9
  df = pd.read_excel(file, engine='openpyxl')
10
  print("Excel file loaded successfully")
11
- print(df.head()) # 데이터 확인용 출력
12
 
13
- # D열 데이터 추출
14
- if 'D' not in df.columns:
15
- raise ValueError("Column 'D' not found in the uploaded file.")
16
- product_names = df['D']
17
- print("Column 'D' data extracted:", product_names.head())
 
 
 
 
 
 
 
18
 
19
  # 키워드 추출 함수
20
  def process_text(text):
@@ -56,7 +63,7 @@ def main():
56
  inputs=gr.File(label="Upload Excel File (.xlsx)"),
57
  outputs="file",
58
  title="Excel Keyword Extractor",
59
- description="Upload an Excel file to extract keywords from column D and calculate their frequencies. The result will be sorted in descending order and saved to a new Excel file."
60
  )
61
  interface.launch()
62
 
 
8
  # 엑셀 파일 읽기
9
  df = pd.read_excel(file, engine='openpyxl')
10
  print("Excel file loaded successfully")
11
+ print("DataFrame columns:", df.columns) # 열 이름 확인
12
 
13
+ # 열 이름 유연하게 처리
14
+ target_column = None
15
+ for column in df.columns:
16
+ if column.strip().lower() == 'd':
17
+ target_column = column
18
+ break
19
+
20
+ if not target_column:
21
+ raise ValueError("No column resembling 'D' found in the uploaded file.")
22
+
23
+ product_names = df[target_column]
24
+ print(f"Column '{target_column}' data extracted:", product_names.head())
25
 
26
  # 키워드 추출 함수
27
  def process_text(text):
 
63
  inputs=gr.File(label="Upload Excel File (.xlsx)"),
64
  outputs="file",
65
  title="Excel Keyword Extractor",
66
+ description="Upload an Excel file to extract keywords from a column resembling 'D' and calculate their frequencies. The result will be sorted in descending order and saved to a new Excel file."
67
  )
68
  interface.launch()
69