DB_JOB/작업파일/공공기관2/10.한국지역난방공사/_efgdup.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

49 lines
1.7 KiB
Python

# -*- coding: utf-8 -*-
import openpyxl, io
from collections import defaultdict
wb=openpyxl.load_workbook("한국지역난방공사.xlsx"); ws=wb.active
out=io.open("_efgdup_out.txt","w",encoding="utf-8")
def w(*a): out.write(" ".join(str(x) for x in a)+"\n")
eff={}
for r in range(3,ws.max_row+1):
for c in range(4,11): eff[(r,c)]=ws.cell(r,c).value
for mr in ws.merged_cells.ranges:
if mr.min_col>=4 and mr.max_col<=10:
v=ws.cell(mr.min_row,mr.min_col).value
for r in range(mr.min_row,mr.max_row+1):
for c in range(mr.min_col,mr.max_col+1): eff[(r,c)]=v
def cell(r,c):
v=eff[(r,c)]; return str(v).strip() if v not in(None,"") else ""
def fullpath(r): return tuple(cell(r,c) for c in range(4,11)) # D..J
def efg(r): return tuple(cell(r,c) for c in range(5,8)) # E,F,G
# full path (D..J) duplicates
fp=defaultdict(list)
for r in range(3,ws.max_row+1):
p=fullpath(r)
if any(p): fp[p].append(r)
w("=== EXACT FULL-PATH (D..J) DUPLICATE ROWS ===")
n=0
for p,rs in fp.items():
if len(rs)>1:
n+=1
w(" rows",rs,"K=",[str(ws.cell(r,11).value) for r in rs])
w(" path:"," > ".join(x for x in p if x))
w(" total exact-full-path dup groups:",n)
# E/F/G triple duplicates (ignore D and H+)
eg=defaultdict(list)
for r in range(3,ws.max_row+1):
t=efg(r)
if any(t): eg[t].append(r)
w("\n=== SAME (E,F,G) triple (ignoring D) ===")
n2=0
for t,rs in eg.items():
if len(rs)>1:
n2+=1
for r in rs:
w(" r%d B%s D=%s | E=%s F=%s G=%s | %s"%(r,ws.cell(r,2).value,cell(r,4),t[0],t[1],t[2],str(ws.cell(r,11).value)[-40:]))
w("")
w(" total EFG-triple dup groups:",n2)
out.close(); print("done")