35 lines
1.2 KiB
Python
35 lines
1.2 KiB
Python
# -*- coding: utf-8 -*-
|
|
import openpyxl, shutil, io
|
|
F="한국의료분쟁조정중재원.xlsx"
|
|
shutil.copy2(F, F.replace(".xlsx","_backup_N재작성전.xlsx"))
|
|
wb=openpyxl.load_workbook(F); ws=wb.active
|
|
# r23~93 최종 N 판정
|
|
IMG={38,40,41,42,43,54,70,71,78,80,81,84,89,90,91}
|
|
VID={88}
|
|
NONE={35,44,52}
|
|
def verdict(r):
|
|
if r in NONE: return "없음"
|
|
if r in VID: return "어문,영상"
|
|
if r in IMG: return "어문,이미지"
|
|
return "어문"
|
|
log=io.open("_apply_log.txt","w",encoding="utf-8")
|
|
nchg=0
|
|
for r in range(23,94):
|
|
if not ws.cell(r,11).value: continue
|
|
cur=ws.cell(r,14).value
|
|
new=verdict(r)
|
|
if (cur or "")!=new:
|
|
log.write("N r%d: %s -> %s\n"%(r,cur,new)); nchg+=1
|
|
ws.cell(r,14).value=new
|
|
# P,Q 비움: O=미부착 전 행(3~93)
|
|
pq=0
|
|
for r in range(3,94):
|
|
if not ws.cell(r,11).value: continue
|
|
O=ws.cell(r,15).value
|
|
if (O is None) or ("미부착" in str(O)) or (str(O).strip()==""):
|
|
if ws.cell(r,16).value not in (None,""): ws.cell(r,16).value=None; pq+=1
|
|
if ws.cell(r,17).value not in (None,""): ws.cell(r,17).value=None
|
|
wb.save(F)
|
|
log.write("\nN변경 %d행, P비움 %d행\n"%(nchg,pq)); log.close()
|
|
print("N변경",nchg,"P비움",pq)
|