Files
HM_project_Viewer_Board/scripts/mark_wehago_2022_no_data.py

34 lines
1.2 KiB
Python

from pathlib import Path
from openpyxl import load_workbook
base = Path(r"\\wsl.localhost\Ubuntu\home\b17301\WEHAGO_DB\data_download\2022")
target = max(base.glob("ledger_*.xlsx"), key=lambda item: item.stat().st_mtime)
no_data = {"377", "400", "636", "643", "805", "819", "820", "824", "843", "932", "936", "950", "951"}
workbook = load_workbook(target)
status_ws = workbook["계정별상태"]
error_ws = workbook["오류_누락"]
for row in status_ws.iter_rows(min_row=2):
code = str(row[0].value)
if code in no_data:
row[2].value = "데이터없음"
row[5].value = "2022년 WEHAGO 계정별원장 화면에서 거래 데이터가 없어 다운로드 파일을 생성하지 않았습니다."
for row_index in range(2, error_ws.max_row + 1):
for col_index in range(1, error_ws.max_column + 1):
error_ws.cell(row_index, col_index).value = None
write_row = 2
for row in status_ws.iter_rows(min_row=2, values_only=True):
code, name, status, file_name, _row_count, message = row[:6]
if status != "정상":
for col_index, value in enumerate([code, name, status, file_name, message], start=1):
error_ws.cell(write_row, col_index).value = value
write_row += 1
workbook.save(target)
print(target)