Kims12 commited on
Commit
c9feecd
·
verified ·
1 Parent(s): e4febc9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -40,7 +40,7 @@ def analyze_reviews(file):
40
  # 새로운 시트에 데이터 작성
41
  logging.info("새로운 시트 생성 및 데이터 작성 시작")
42
  with pd.ExcelWriter(file_bytes, engine='openpyxl', mode='a', if_sheet_exists='replace') as writer:
43
- review_counts.to_excel(writer, sheet_name='월별 리뷰건수', index=False, header=['년월', '리뷰건수'])
44
  logging.info("새로운 시트에 데이터 작성 완료")
45
 
46
  # 결과 파일 저장
@@ -53,12 +53,12 @@ def analyze_reviews(file):
53
  for sheet_name in xls.sheet_names:
54
  df_sheet = pd.read_excel(xls, sheet_name=sheet_name, engine='openpyxl')
55
  df_sheet.to_excel(writer, sheet_name=sheet_name, index=False)
56
- # 추가된 '월별 리뷰건수' 시트 추가
57
- review_counts.to_excel(writer, sheet_name='월별 리뷰건수', index=False, header=['년월', '리뷰건수'])
58
  output.seek(0)
59
  logging.info("결과 파일 저장 완료")
60
 
61
- return output
 
62
  except Exception as e:
63
  logging.error(f"분석 과정 중 오류: {e}")
64
  return f"분석 과정에서 오류가 발생했습니다: {e}"
 
40
  # 새로운 시트에 데이터 작성
41
  logging.info("새로운 시트 생성 및 데이터 작성 시작")
42
  with pd.ExcelWriter(file_bytes, engine='openpyxl', mode='a', if_sheet_exists='replace') as writer:
43
+ review_counts.to_excel(writer, sheet_name='월별 리뷰건수', index=False, columns=['년월', '리뷰건수'])
44
  logging.info("새로운 시트에 데이터 작성 완료")
45
 
46
  # 결과 파일 저장
 
53
  for sheet_name in xls.sheet_names:
54
  df_sheet = pd.read_excel(xls, sheet_name=sheet_name, engine='openpyxl')
55
  df_sheet.to_excel(writer, sheet_name=sheet_name, index=False)
56
+ # 이미 '월별 리뷰건수' 시트가 추가되었으므로 추가로 작성할 필요 없음
 
57
  output.seek(0)
58
  logging.info("결과 파일 저장 완료")
59
 
60
+ # BytesIO 데이터를 바이트로 변환하고 파일 이름과 함께 반환
61
+ return (output.getvalue(), "분석된_리뷰.xlsx")
62
  except Exception as e:
63
  logging.error(f"분석 과정 중 오류: {e}")
64
  return f"분석 과정에서 오류가 발생했습니다: {e}"