# -*- coding: utf-8 -*- import json, openpyxl, sys sys.stdout.reconfigure(encoding='utf-8') F='전북특별자치도_완주군.xlsx' d=json.load(open('_ncrawlC.json',encoding='utf-8')) KEEP={378,382,383,385,494,495,496,498,502,503,524,541,555,574,575,576,593,594} wb=openpyxl.load_workbook(F); ws=wb.active ch=0; pimg=0; pkeep=0; brd=0; non=0 for r,v in d.items(): r=int(r) if r<335: continue L=v['L']; det=v['det']; old=ws.cell(r,14).value if L=='페이지': new='어문' if r in KEEP else det if r in KEEP and det=='어문,이미지': pkeep+=1 else: new=det if (new or '')!=(old or ''): ws.cell(r,14).value=new; ch+=1 if L=='페이지' and new=='어문,이미지': pimg+=1 elif L=='게시판' and new=='어문,이미지': brd+=1 elif new=='없음': non+=1 wb.save(F) print('N변경 %d | 페이지→이미지 %d | 페이지어문유지 %d | 게시판→이미지 %d | →없음 %d'%(ch,pimg,pkeep,brd,non))