[Python] HWP 파일을 불러오기
리눅스 백엔드에서 HWP 파일을 처리하는 것은 상당히 골치아픈 일입니다.
다행히 Python에는 HWP 파일을 핸들링하는 모듈도 있습니다 ^^
1. Olefile
[code]
import olefile
f = olefile.OleFileIO('한컴파일.hwp') # HWP 파일 열기
encoded_text = f.openstream('PrvText').read() # PrvText 스트림의 내용 꺼내기
decoded_text = encoded_text.decode('UTF-16') # 유니코드를 UTF-16으로 디코딩
print(decoded_text)
[/code]
Olefile 모듈은 Microsoft OLE2 파일을 조작하기 위한 모듈로서
위와 같은 방법으로 한컴 HWP 파일도 불러올 수 있습니다 ^^
2. PyHWP의 HWP5TXT
[code]
from subprocess import Popen, PIPE
file = '한컴파일.hwp'
process = Popen(['hwp5txt', file], stdout=PIPE, stderr=PIPE)
stdout, stderr = process.communicate()
data = stdout.decode('utf-8')
print(data)
[/code]
PyHWP 모듈은 Olefile에 dependent하기 때문에
Olefile에서 제대로 불러오지 못하는 HWP 파일의 경우
PyHWP에서도 마찬가지로 잘 불러올 수 없다는 문제가 있습니다.
그러한 경우에 위와 같이 PyHWP 설치시 함께 설치되는 hwp5txt.exe 파일을 이용하면
대부분의 문제를 해결할 수 있습니다 ^^
다만 EXE 파일이므로 윈도우 환경에서만 실행 가능하다는 한계가 있습니다.
게시글 목록
| 번호 | 제목 |
|---|---|
| 16329 |
node.js
Node.js MongoDB 정렬
|
| 16328 |
node.js
정규 표현식으로 필터링
|
| 16327 |
node.js
환경설정 - dotenv
|
| 16326 |
node.js
Node.js MongoDB 쿼리
|
| 16325 | |
| 16324 |
node.js
nodejs MongoDB Find All
|
| 16323 |
node.js
Node.js MongoDB find
|
| 16322 |
node.js
node.js MongoDB _id Field
|
| 16321 |
node.js
node.js MongoDB 여러 문서 삽입
|
| 16320 |
node.js
Node.js MongoDB Insert
|
| 16319 |
node.js
Node.js MongoDB 컬렉션 만들기
|
| 16318 |
node.js
Node.js MongoDB 데이터베이스 생성
|
| 16317 |
node.js
Node.js MongoDB 설치
1
|
| 16316 |
node.js
Node.js 전자 메일 보내기
|
| 16315 |
node.js
Node.js 파일 업로드
|
| 16310 |
node.js
node.js 이벤트 모듈
|
| 16309 |
node.js
node.js NPM
|
| 16308 |
node.js
node.js 파일삭제, 파일 이름 바꾸기
|
| 16305 |
node.js
nodejs 기초문법 - 클래스
3
|
| 16304 |
node.js
nodejs 기초문법 - 조건문 반복문
|
| 16303 |
node.js
nodejs .기초문법 변수선언 , 함수선언
|
| 16302 |
node.js
nodejs 파일 업데이트
|
| 16301 |
node.js
nodejs 파일 만들기
|
| 16300 |
node.js
nodejs 파일 읽기
1
|
| 16299 |
node.js
Node.js 쿼리 문자열 읽기 , 쿼리 문자열 분할하기
|
| 16298 |
node.js
NOde.js HTTP 모듈
|
| 16297 |
node.js
Node.js 모듈
|
| 16295 |
node.js
nods.js 시작하기
|
| 16294 |
node.js
node.js 란 2번째
|
| 16293 |
node.js
Node.js란
1
|
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기