Files
homeclaw/.smallclaw/users/papa/workspace/update_prize_v3.py
T
2026-05-01 23:23:11 +09:00

47 lines
1.3 KiB
Python

import openpyxl
import os
files = os.listdir('uploads')
target_file = None
for f in files:
if f.endswith('.xlsx') and '사ì›' in f:
target_file = os.path.join('uploads', f)
break
if not target_file:
# Try another way if the first one fails
for f in files:
if f.endswith('.xlsx'):
target_file = os.path.join('uploads', f)
break
if not target_file:
print("No xlsx file found.")
exit()
print(f"Loading {target_file}...")
wb = openpyxl.load_workbook(target_file)
for sheet_name in wb.sheetnames:
ws = wb[sheet_name]
# Find the lookup table "달성률 등급"
# The user's text shows:
# 달성률 | 등급 | 상금
# 0 | Level 1 | 0
# ...
for row in ws.iter_rows():
for cell in row:
if cell.value == "상금":
col = cell.column
row_start = cell.row + 1
for r in range(row_start, ws.max_row + 1):
c = ws.cell(row=r, column=col)
if isinstance(c.value, (int, float)):
c.value *= 2
print(f"Updated '상금' in sheet {sheet_name}")
output_path = 'uploads/사원_보고서_상금2배.xlsx'
wb.save(output_path)
print(f"Saved to {output_path}")