DB_JOB/작업파일/완료/광역_사이트맵/충청북도/_cy4_applyN.py
hehihoho3 df16c98366 백업: DB수집 전체 스냅샷 (공공기관2 정리 전)
공공기관2 작업 중. _temp 몽타주(재생성가능)는 제외.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-18 18:15:40 +09:00

36 lines
1.8 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# -*- coding: utf-8 -*-
# 청양 175+ N 이미지 적용: 몽타주판정 백업(cy2) 이미지라벨. 영상/오디오 보존. 사이트/없음 제외.
import openpyxl, io, sys
from collections import Counter
sys.stdout=io.TextIOWrapper(sys.stdout.buffer,encoding='utf-8')
F=r'D:\01.프로젝트\DB수집\작업파일\광역_사이트맵\충청남도\13.청양군\충청남도_청양군.xlsx'
BK=r'D:\01.프로젝트\DB수집\작업파일\광역_사이트맵\충청남도\13.청양군\충청남도_청양군_backup_LMNO재수집전.xlsx'
# 몽타주 이미지 판정(현재 행번호)
MONT={175,176,180,181,182,190, 194,195,196,201,202,215,
243,254,260,261,262,263,264,265,266, 267,275,281,282,283,291,292,294,297,298,
299,300,301,302,303,304,305,306,307,308,331,334, 343,353,392,410,413,414}
wb=openpyxl.load_workbook(F); ws=wb.active
def lab(ws,r): return str(ws.cell(r,8).value or ws.cell(r,7).value or ws.cell(r,6).value or ws.cell(r,5).value or '')
# 백업 이미지 라벨(175+)
wb2=openpyxl.load_workbook(BK); ws2=wb2.active
bklab=set()
for r in range(175,ws2.max_row+1):
if '이미지' in str(ws2.cell(r,14).value or ''): bklab.add(lab(ws2,r))
# 현재 행 중 라벨이 백업이미지인 행 몽타주
imgrows=set(MONT)
for r in range(175,ws.max_row+1):
if lab(ws,r) in bklab: imgrows.add(r)
chg=0
for r in sorted(imgrows):
cur=str(ws.cell(r,14).value or '')
if cur in ('','없음'): continue # 사이트/빈게시판 제외
if '이미지' in cur: continue
extra=[]
if '영상' in cur: extra.append('영상')
if '오디오' in cur: extra.append('오디오')
ws.cell(r,14).value='어문,이미지'+(','+','.join(extra) if extra else '')
chg+=1
wb.save(F)
print('이미지 적용',chg,'| 대상행',len(imgrows))
print('N분포',dict(Counter(ws.cell(r,14).value for r in range(175,ws.max_row+1))))