Files
Aislo/resources/tester/scratch/restore_1_2_2_table.py
T

59 lines
2.5 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import sys, os, re
sys.stdout.reconfigure(encoding='utf-8')
fpath = "resources/knowledge/original/원가계산/건설공사_표준품셈/01_공통부문/제1장_적용기준.md"
with open(fpath, 'r', encoding='utf-8') as f:
text = f.read()
# Replace the collapsed row at 1-2-2 (starts with | 돌 쌓 기 및 돌 붙 임 사 석)
# We reconstruct the exact 34 rows from PDF Page 61
restored_rows = """| 돌 쌓 기 및 돌 붙 임 | ㎝ | - | ㎡ | 1 | |
| 사 석 ( 捨 石 ) | ㎝ | - | ㎥ | 1 | |
| 다 듬 돌 ( 切 石 , 板 石 ) | ㎝ | - | 개 | 2 | |
| 벽 돌 | ㎜ | - | 개 | - | |
| 블 록 | ㎜ | - | 개 | - | |
| 시 멘 트 | - | - | ㎏ | - | |
| 모 르 타 르 | - | - | ㎥ | 2 | |
| 콘 크 리 트 | - | - | ㎥ | 2 | |
| 석 분 | - | - | ㎏ | - | |
| 석 회 | - | - | ㎏ | - | |
| 화 산 회 | - | - | ㎏ | - | |
| 아 스 팔 트 | - | - | ㎏ | - | |
| 목 재 ( 판 재 ) | 길이m | 1 | ㎡ | 2 | |
| 목 재 ( 판 재 ) | 폭,두께 | 1 | ㎥ | 3 | |
| 목 재 ( 판 재 ) | ㎝ | 1 | ㎥ | 3 | |
| 합 판 | ㎜ | - | 장 | 1 | |
| 말 뚝 | 길이m 지름㎜ | 1 - | 개 | - | |
| 철 강 재 | ㎜ | - | ㎏ | 3 | 총량표시는 ton으로 한다. |
| 용 접 봉 | ㎜ | - | ㎏ | 1 | |
| 구 리 판 , 함 석 류 | - | - | ㎡ | 2 | |
| 철 근 | ㎜ | - | ㎏ | - | |
| 볼 트 , 너 트 | ㎜ | - | 개 | - | |
| 꺽 쇠 | ㎜ | - | 개 | - | |
| 철 선 류 | ㎜ | 1 | ㎏ | 2 | |
| P C 강 선 | - | - | ㎏ | 2 | |
| 돌 망 태 | 길이m 지름m 높이m | 1 위 - - | m 개 | 1 - | 망눈(網目)㎝ |
| 로 프 류 | ㎜ | - | m | 1 | |
| 못 | 길이㎝ | 1 | ㎏ | 2 | |
| 석 유 , 휘 발 유 , 모 빌 유 | - | - | | 2 | |
| 구 리 스 | - | - | ㎏ | 2 | |
| 넝 마 | - | - | ㎏ | 2 | |
| 화 약 류 | - | - | ㎏ | 3 | |
| 뇌 관 | - | - | 개 | - | |
| 도 화 선 | - | - | m | 1 | |
| 석 탄 , 목 탄 , 코 크 스 | - | - | ㎏ | 1 | |
| 산 소 | - | - | | - | |
| 카 바 이 트 | - | - | ㎏ | 1 | |"""
# Target pattern in text
pattern = re.compile(r'\|\s*돌\s*쌓\s*기\s*및\s*돌\s*붙\s*임\s*사\s*석.*?\n', re.DOTALL)
m = pattern.search(text)
if m:
print(f"Found collapsed row, length={len(m.group(0))}")
new_text = text[:m.start()] + restored_rows + '\n' + text[m.end():]
with open(fpath, 'w', encoding='utf-8') as f:
f.write(new_text)
print("Successfully replaced collapsed row with 37 distinct rows in 1-2-2!")
else:
print("Collapsed row not matched!")