1
file.docをファイルに変換するためにPythonスクリプトを使用しています。 TXT。私のコードは次のとおりです。windowsにantiwordをインストールしてPythonで使用する方法
from subprocess import Popen, PIPE
from docx import opendocx, getdocumenttext
#http://stackoverflow.com/questions/5725278/python-help-using-pdfminer-as-a-library
from pdfminer.pdfinterp import PDFResourceManager, PDFPageInterpreter
from pdfminer.converter import TextConverter
from pdfminer.layout import LAParams
from pdfminer.pdfpage import PDFPage
from cStringIO import StringIO
import os
def document_to_text(filename, file_path):
if filename[-4:] == ".doc":
cmd = ['antiword', file_path]
p = Popen(cmd, stdout=PIPE)
stdout, stderr = p.communicate()
return stdout.decode('ascii', 'ignore')
elif filename[-5:] == ".docx":
document = opendocx(file_path)
paratextlist = getdocumenttext(document)
newparatextlist = []
for paratext in paratextlist:
newparatextlist.append(paratext.encode("utf-8"))
return '\n\n'.join(newparatextlist)
i「はantiword」をインストールする必要がありますが、問題は、私はそれを行う方法がわからないということです上記のスクリプトを使用するために。 ここに「アンチワード」をダウンロードするリンクがあります:http://www-stud.rbi.informatik.uni-frankfurt.de/~markus/antiword/
誰かが私を助けることができますか?
あなたがにリンクされたページを読んでいる場合は、[インストール手順](http://www-stud.rbi.informatik.uni-frankfurt.de/~markus/antiword/00READMEを見つけることができます。勝つ)。 – Matthias