import re, os, glob, sys sys.stdout.reconfigure(encoding='utf-8') base_dirs = [ 'resources/knowledge/original/원가계산/건설공사_표준품셈/02_토목부문', 'resources/knowledge/original/원가계산/건설공사_표준품셈/03_건축부문', 'resources/knowledge/original/원가계산/건설공사_표준품셈/04_기계설비부문', 'resources/knowledge/original/원가계산/건설공사_표준품셈/05_유지관리부문', ] results = [] for bdir in base_dirs: for fpath in glob.glob(os.path.join(bdir, '*.md')): fname = os.path.basename(fpath) with open(fpath, encoding='utf-8') as f: lines = f.readlines() in_table = False table_start = 0 table_lines = [] for idx, line in enumerate(lines): stripped = line.strip() if stripped.startswith('|') and stripped.endswith('|'): if not in_table: in_table = True table_start = idx + 1 table_lines = [] table_lines.append((idx + 1, stripped)) else: if in_table: in_table = False # Analyze table # Check if any row has cells with multiple numbers separated by spaces (squashed rows) for lno, row_str in table_lines[2:]: # skip header and divider cells = [c.strip() for c in row_str.split('|')[1:-1]] for c_idx, cell in enumerate(cells): # check if cell has 4+ space-separated numbers or words parts = cell.split() if len(parts) >= 4 and any(re.match(r'^[0-9~.()%]+$', p) for p in parts): # Could be squashed results.append({ 'file': fname, 'line': lno, 'cell_idx': c_idx, 'cell': cell[:80] }) break print(f"Found {len(results)} potential squashed rows:") for r in results: print(f" {r['file']} L{r['line']}: [Col {r['cell_idx']}] {r['cell']}")