파일 삭제 및 새로운 채점 기준 추가

This commit is contained in:
devdra9
2025-01-16 18:34:07 +09:00
parent ba29501ed6
commit 894d6be884
75 changed files with 1647 additions and 3362 deletions

View File

@@ -1,15 +1,22 @@
import base64
import re
from lxml import etree as ET
xml_path = r"C:\Users\dra\project\HWP-Scoring\output\워드(한글)-009866-성유나.hml"
tree = ET.parse(xml_path)
root = tree.getroot()
# xpath로 바이너리 부분추출
binary_data = root.xpath('//BINDATA[@Id=//BINITEM[@Format="OLE"]/@BinData]/text()')
binary_data = binary_data[0].encode('utf-8')
# 파일을 읽어들입니다.
with open('./chartBinData2', 'rb') as file:
encoded_data = file.read()
# with open('./chartBinData2', 'rb') as file:
# encoded_data = file.read()
# encoded_data 내에 존재하는 <BINDATA ...> ... </BINDATA> 태그를 찾아서 삭제
# <BINDATA ...> 태그는 base64 디코딩을 수행할 때 오류가 발생하므로 삭제합니다.
# <BINDATA ...> 태그와 그 내부 내용을 삭제합니다.
encoded_data = re.sub(b'<BINDATA.*?>', b'', encoded_data)
encoded_data = re.sub(b'<BINDATA.*?>', b'', binary_data)
# encoded_data = re.sub(b'<BINDATA.*?>', b'', encoded_data)
# print(encoded_data)
encoded_data = encoded_data.replace(b'</BINDATA>', b'')
encoded_data = encoded_data.replace(b'\r\n', b'')