# -*- coding: utf-8 -*- import openpyxl, io wb=openpyxl.load_workbook("한국의료분쟁조정중재원.xlsx"); ws=wb.active o=io.open("_dump_out.txt","w",encoding="utf-8") eff={} for r in range(3,ws.max_row+1): for c in range(4,11): eff[(r,c)]=ws.cell(r,c).value for mr in ws.merged_cells.ranges: if mr.min_row>=3 and mr.min_col>=4 and mr.max_col<=10: v=ws.cell(mr.min_row,mr.min_col).value for r in range(mr.min_row,mr.max_row+1): for c in range(mr.min_col,mr.max_col+1): eff[(r,c)]=v def E(r,c): v=eff.get((r,c)); return str(v).strip() if v not in(None,"") else "" o.write("max_row %d\n"%ws.max_row) for r in range(3,ws.max_row+1): B=ws.cell(r,2).value path=" > ".join(E(r,c) for c in range(4,11) if E(r,c)) L=ws.cell(r,12).value;M=ws.cell(r,13).value;N=ws.cell(r,14).value O=ws.cell(r,15).value;P=ws.cell(r,16).value;Q=ws.cell(r,17).value K=ws.cell(r,11).value o.write("r%d B%s | L=%s M=%s N=%s | O=%s P=%s Q=%s | %s | %s\n"%( r,B,L,M,N,O,P,Q,path,(str(K)[:70] if K else ""))) o.close();print("done")