import sys, io, shutil, os
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
import openpyxl

PKG = r'D:\01.프로젝트\DB수집\작업파일\_제출패키지_2026-06-03\프리랜서1\충청남도_부여군.xlsx'
WRK = r'D:\01.프로젝트\DB수집\작업파일\광역_사이트맵\충청남도\7.부여군\충청남도_부여군.xlsx'

for P in (PKG, WRK):
    BK = P.replace('.xlsx', '_backup_행높이정규화전.xlsx')
    if not os.path.exists(BK):
        shutil.copy2(P, BK)
    wb = openpyxl.load_workbook(P); ws = wb.active
    fixed = 0
    for r in range(1, ws.max_row + 1):
        if ws.row_dimensions[r].height not in (15.0, None):
            ws.row_dimensions[r].height = 15.0
            fixed += 1
    wb.save(P)
    print(f'{os.path.basename(P)}: 높이정규화 {fixed}행 -> 15.0, saved (backup {os.path.basename(BK)})')

# verify
for tag, P in (('PKG', PKG), ('WRK', WRK)):
    ws = openpyxl.load_workbook(P).active
    from collections import Counter
    hc = Counter(ws.row_dimensions[r].height for r in range(1, ws.max_row + 1))
    print(f'{tag} height histogram: {dict(hc)}  max_row={ws.max_row}')
