DB_JOB/작업파일/_chk_S.py
hehihoho3 df16c98366 백업: DB수집 전체 스냅샷 (공공기관2 정리 전)
공공기관2 작업 중. _temp 몽타주(재생성가능)는 제외.

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

42 lines
1.9 KiB
Python

# -*- coding: utf-8 -*-
import sys, os
sys.stdout.reconfigure(encoding='utf-8')
import openpyxl
from openpyxl.utils import get_column_letter
BASE = os.path.join(os.path.dirname(os.path.abspath(__file__)), '광역_사이트맵')
FILES = [
('당진시', '충청남도/5.당진시/충청남도_당진시.xlsx'),
('부여군', '충청남도/7.부여군/충청남도_부여군.xlsx'),
('고창군', '전북특별자치도/1.고창군/전북특별자치도_고창군.xlsx'),
('군산시', '전북특별자치도/2.군산시/전북특별자치도_군산시.xlsx'),
('남원시', '전북특별자치도/4.남원시/전북특별자치도_남원시.xlsx'),
('무주군', '전북특별자치도/5.무주군/전북특별자치도_무주군.xlsx'),
('김제시', '전북특별자치도/3.김제시/전북특별자치도_김제시.xlsx'),
]
# 헤더 확인 (1행은 첫 파일 기준)
p0 = os.path.join(BASE, FILES[0][1].replace('/', os.sep))
wb = openpyxl.load_workbook(p0); ws = wb.active
print('=== 헤더(첫 파일 당진시) 1~2행 R..AA ===')
for r in (1, 2):
print(f' row{r}:', [(get_column_letter(c), ws.cell(r, c).value) for c in range(18, 28) if ws.cell(r, c).value not in (None, '')])
wb.close()
print('\n=== S열(col19) 비어있지 않은 셀 ===')
for name, rel in FILES:
p = os.path.join(BASE, rel.replace('/', os.sep))
wb = openpyxl.load_workbook(p); ws = wb.active
hits = []
for r in range(3, ws.max_row + 1):
v = ws.cell(r, 19).value
link = ws.cell(r, 19).hyperlink
if v not in (None, '') or link:
b = ws.cell(r, 2).value
label = ws.cell(r, 7).value or ws.cell(r, 6).value or ws.cell(r, 5).value or ws.cell(r, 4).value
hits.append((r, b, label, v, link.target if link else None))
print(f'\n[{name}] S열 입력 {len(hits)}')
for r, b, label, v, lk in hits:
print(f' r{r} B={b} [{label}] S={v!r}' + (f' | hyperlink={lk}' if lk else ''))
wb.close()