공공기관2 작업 중. _temp 몽타주(재생성가능)는 제외. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
33 lines
1.5 KiB
Python
33 lines
1.5 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""군산·고창·김제 S열(비고) 지정 셀의 텍스트만 삭제. 그 외 일절 무변경. 백업."""
|
|
import sys, os, shutil
|
|
sys.stdout.reconfigure(encoding='utf-8')
|
|
import openpyxl
|
|
|
|
BASE = os.path.join(os.path.dirname(os.path.abspath(__file__)), '광역_사이트맵')
|
|
# 기관: (상대경로, [(행, 기대값)]) — 기대값과 다르면 건너뜀(안전가드)
|
|
TARGETS = {
|
|
'고창군': ('전북특별자치도/1.고창군/전북특별자치도_고창군.xlsx',
|
|
[(98, '접근 실패')]),
|
|
'군산시': ('전북특별자치도/2.군산시/전북특별자치도_군산시.xlsx',
|
|
[(177, '외부링크'), (192, '외부링크'), (244, '외부링크'), (247, '외부링크')]),
|
|
'김제시': ('전북특별자치도/3.김제시/전북특별자치도_김제시.xlsx',
|
|
[(135, '접근 실패'), (258, '접근 실패'), (352, '접근 실패'), (361, '접근 실패')]),
|
|
}
|
|
S = 19 # 컬럼 S
|
|
|
|
for name, (rel, cells) in TARGETS.items():
|
|
p = os.path.join(BASE, rel.replace('/', os.sep))
|
|
shutil.copyfile(p, p.replace('.xlsx', '_backup_S삭제전.xlsx'))
|
|
wb = openpyxl.load_workbook(p); ws = wb.active
|
|
cleared, skipped = [], []
|
|
for r, expect in cells:
|
|
cur = ws.cell(r, S).value
|
|
if cur == expect:
|
|
ws.cell(r, S).value = None
|
|
cleared.append(r)
|
|
else:
|
|
skipped.append((r, cur))
|
|
wb.save(p)
|
|
print(f'[{name}] 삭제 {len(cleared)}건 {cleared}' + (f' | 건너뜀(값불일치) {skipped}' if skipped else ''))
|