# -*- coding: utf-8 -*- # 청양 123행+ N 재판정 적용(선생님 기준): 사이트→N비움 / IMG→어문,이미지 / det없음&기존없음→없음 / 그외→어문. 영상·오디오 보존. 1~122 불변. import openpyxl, json, sys, io sys.stdout=io.TextIOWrapper(sys.stdout.buffer,encoding='utf-8') F='..\\충청남도\\13.청양군\\충청남도_청양군.xlsx' r=json.load(open('_cy2_ncrawl.json',encoding='utf-8')) IMG={127,133,141,142,143,170,171,172,176,177,178,186,190,191,192,198,211,225,226,236,239,248, 255,256,260,261,269,275,276,277,285,286,288,291,292,302,305,314,324,363,381,385,386,389,390} wb=openpyxl.load_workbook(F); ws=wb.active chg=0; site_cleared=0 for row in range(123, ws.max_row+1): L=ws.cell(row,12).value if L not in ('페이지','게시판','사이트'): continue cur=str(ws.cell(row,14).value or '') if L=='사이트': if ws.cell(row,14).value is not None: ws.cell(row,14).value=None; site_cleared+=1 continue det=r.get(str(row),{}).get('det','어문') if 'nav_fail' in r.get(str(row),{}).get('why','') or 'ERR' in r.get(str(row),{}).get('why',''): continue if row in IMG: base='어문,이미지' elif det=='없음' and ('없음' in cur or cur==''): base='없음' else: base='어문' extra=[] if base!='없음': if '영상' in cur: extra.append('영상') if '오디오' in cur: extra.append('오디오') new=base+(','+','.join(extra) if extra else '') if new!=cur: ws.cell(row,14).value=new; chg+=1 wb.save(F) from collections import Counter d=Counter(ws.cell(rr,14).value for rr in range(3,ws.max_row+1)) print('123+ N변경 %d | 사이트N비움 %d | 전체N %s'%(chg,site_cleared,dict(d)))