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

32 lines
1.4 KiB
Python

import openpyxl
filename = 'uploads/ì‚¬ì› ë³´ê³ ì„œ-완성.xlsx'
wb = openpyxl.load_workbook(filename)
for sheet_name in wb.sheetnames:
ws = wb[sheet_name]
# Find the "달성률 등급" table and update prize money
found_table = False
for row in ws.iter_rows():
for cell in row:
if cell.value == "달성률 등급":
found_table = True
# If we are in the table and the cell is a number and looks like a prize
# Based on the user's text, the prize money is in the 3rd column of that table
# Let's look for the header "상금"
if cell.value == "상금":
# Start updating from the next row
header_row = cell.row
col_idx = cell.column
for r in range(header_row + 1, ws.max_row + 1):
prize_cell = ws.cell(row=r, column=col_idx)
if isinstance(prize_cell.value, (int, float)) and prize_cell.value > 0:
prize_cell.value *= 2
elif prize_cell.value is None or prize_cell.value == "":
# Stop if we hit an empty row after the table
break
wb.save('uploads/사원_보고서_상금수정.xlsx')
print("Updated prize money and saved to uploads/사원_보고서_상금수정.xlsx")