import sys, io
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
import openpyxl
P = r'D:\01.프로젝트\DB수집\작업파일\광역_사이트맵\충청남도\10.아산시\충청남도_아산시.xlsx'
wb = openpyxl.load_workbook(P)
ws = wb.active

print('=== S column non-empty (all rows) ===')
for r in range(3, ws.max_row+1):
    v = ws[f'S{r}'].value
    if v is not None and str(v).strip():
        print(f'r{r}: S={v!r}  K={ws[f"K{r}"].value!r}')

print('\n=== Rows where O is a 공공누리 type (not 미부착/empty) ===')
for r in range(3, ws.max_row+1):
    o = ws[f'O{r}'].value
    if o and str(o).strip() and str(o).strip() != '미부착':
        print(f'r{r}: O={o!r} P={ws[f"P{r}"].value!r} Q={ws[f"Q{r}"].value!r} R={ws[f"R{r}"].value!r} N={ws[f"N{r}"].value!r} | F={ws[f"F{r}"].value!r} G={ws[f"G{r}"].value!r} K={ws[f"K{r}"].value!r}')

print('\n=== count L distribution rows 37+ ===')
from collections import Counter
c = Counter(ws[f'L{r}'].value for r in range(37, ws.max_row+1))
print(c)
