接受跟踪更改并使用 CATDOC 将 .doc 转换为 .txt

Accept track changes and convert .doc to .txt using CATDOC

如何在使用 catdoc 将 .doc 文件转换为 .txt 文件时接受音轨更改?

假设有两个文件'original.doc'和'modified.doc'。

'original.doc'有如下句子:this a test sentence 'modified.doc'有如下句子:this is a test statement

当我将 modified.doc 转换为 .txt 文件而不是 this is a test statement 我得到 this is a test sentence statement

我正在使用下面的代码。

def doc_to_text_catdoc(filename):
(fi, fo, fe) = os.popen3('catdoc -w "%s"' % filename)
fi.close()
retval = fo.read()
erroroutput = fe.read()
fo.close()
fe.close()
if not erroroutput:
    return retval
else:
    raise OSError("Executing the command caused an error: %s" % erroroutput)

使用 Antiword 解决了问题。

(fi, fo, fe) = os.popen3('antiword -f "%s"' % filename)