DB_JOB/작업파일/공공기관2/10.한국지역난방공사/_dupscan.py
hehihoho3 b0acd1e705 백업: 셀병합 정상화(D~J)+KDHC 옵션2/행높이17, 오늘(06-21) 제출 17곳 검수·압축
- 공공기관2/3 작업본 + 오늘 제출 17곳 D~J 카테고리 셀병합 정상화
- 한국지역난방공사 옵션2(고아셀 F98 수정)+전행 높이17
- 제출_프리랜서2_2026-06-21.zip 생성(17개 xlsx, 2,468행)

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

47 lines
1.5 KiB
Python

# -*- coding: utf-8 -*-
import openpyxl, io, sys
from collections import defaultdict
wb=openpyxl.load_workbook("한국지역난방공사.xlsx")
ws=wb.active
out=io.open("_dupscan_out.txt","w",encoding="utf-8")
def w(*a): out.write(" ".join(str(x) for x in a)+"\n")
rows=[]
for r in range(3, ws.max_row+1):
B=ws.cell(r,2).value
D2J=[ws.cell(r,c).value for c in range(4,11)] # D..J
K=ws.cell(r,11).value
L=ws.cell(r,12).value; M=ws.cell(r,13).value; N=ws.cell(r,14).value
rows.append((r,B,D2J,K,L,M,N))
w("max_row",ws.max_row,"data rows",len(rows))
# 1) exact same K URL appearing on multiple rows
byK=defaultdict(list)
for r,B,d,K,L,M,N in rows:
if K: byK[str(K).strip()].append(r)
w("\n=== DUP by identical K URL ===")
dupK=0
for K,rs in byK.items():
if len(rs)>1:
dupK+=1
w("URL:",K)
for rr in rs:
row=next(x for x in rows if x[0]==rr)
lbl=" > ".join([str(v) for v in row[2] if v])
w(" row",rr,"B="+str(row[1]),"L="+str(row[4]),"M="+str(row[5]),"|",lbl)
w("total identical-URL groups:",dupK)
# 2) same full D..J label path AND same K (true dup row)
byPath=defaultdict(list)
for r,B,d,K,L,M,N in rows:
key=(tuple(str(x).strip() if x else "" for x in d), str(K).strip() if K else "")
byPath[key].append(r)
w("\n=== DUP by identical (D..J path + K) ===")
for key,rs in byPath.items():
if len(rs)>1:
w("rows",rs,"path=", " > ".join([x for x in key[0] if x]), "| K=",key[1])
out.close()
print("done")