# -*- coding: utf-8 -*- import openpyxl, sys from openpyxl.utils import get_column_letter sys.stdout.reconfigure(encoding='utf-8') new=openpyxl.load_workbook('_충청남도_서천군_NEW.xlsx').active def show(r): vals=[] for c in range(2,16): v=new.cell(r,c).value if v is not None: vals.append(f'{get_column_letter(c)}={str(v)[:14]}') print(f'R{r:>3} '+' | '.join(vals)) # 문화체육과 group (6 tabs incl bbs) for r in range(3,new.max_row+1): if new.cell(r,6).value=='문화체육과': print('=== 문화체육과 ==='); for k in range(r,r+6): show(k) break # F-merge of 민원편의시책 fm=[str(m) for m in new.merged_cells.ranges if m.min_col==6 and any(new.cell(m.min_row,6).value=='민원편의시책' for _ in [0])] print('민원편의시책 F-merge:', [str(m) for m in new.merged_cells.ranges if m.min_col==6 and new.cell(m.min_row,6).value=='민원편의시책']) # last 5 data rows print('=== last 5 rows ===') for r in range(new.max_row-4, new.max_row+1): show(r) # any fully-empty data rows? empty=[r for r in range(3,new.max_row+1) if all(new.cell(r,c).value is None for c in range(2,28))] print('fully empty data rows:', empty) # bbs M=0 vs >0 among new mzero=sum(1 for r in range(3,new.max_row+1) if new.cell(r,12).value=='게시판' and new.cell(r,13).value==0) print('게시판 rows with M=0:', mzero, '/ total 게시판', sum(1 for r in range(3,new.max_row+1) if new.cell(r,12).value=='게시판'))