# coding: utf-8
import openpyxl, io
wb=openpyxl.load_workbook('한국인터넷진흥원.xlsx'); ws=wb.active
out=io.open('_onq_out.txt','w',encoding='utf-8')
from collections import Counter
nc=Counter(); oc=Counter()
for r in range(3,ws.max_row+1):
    N=ws.cell(r,14).value; O=ws.cell(r,15).value; P=ws.cell(r,16).value; Q=ws.cell(r,17).value
    nc[N]+=1; oc[(O,P,Q)]+=1
out.write('=== N distribution ===\n')
for k,v in nc.most_common(): out.write('  %r : %d\n'%(k,v))
out.write('=== O/P/Q distribution ===\n')
for k,v in oc.most_common(): out.write('  %r : %d\n'%(k,v))
# sample a few rows N
out.write('=== sample N by row ===\n')
for r in [13,14,15,16,17,43,44,47,86,88]:
    out.write('  r%d %r N=%r O=%r\n'%(r,ws.cell(r,5).value,ws.cell(r,14).value,ws.cell(r,15).value))
out.close(); print(open('_onq_out.txt',encoding='utf-8').read())
