【发布时间】:2018-12-05 13:14:25
【问题描述】:
如上所述,我在 python 中使用 tika 从多个文档中提取文本,但在一个特定的 pdf 中,它在我的开发机器 (MacBook Pro) 上提取文本,而不是在 Windows Server 2012 上,它返回一个“NoneType” '。
非常混乱,一开始我以为是库,但它使用的是来自 apache (1.19.1) 的相同 jar 文件
try:
headers = {'X-Tika-PDFextractInlineImages': 'true',}
data = parser.from_file(pathtofile, serverEndpoint=self.TIKA_SERVER, headers=headers)
charstoreturn = data['content'].strip().split()[:limit]
charstoreturn = ' '.join(charstoreturn).replace("\n", " ").replace('"', "'").replace(",","").replace("’","'")
return True, charstoreturn
except Exception as err:
return False, "error {} on file: {}.\n".format(str(err), pathtofile)
TIKA_SERVER 是“http://localhost:1234” pathtofile 是我正在测试失败的文件
Windows 上的错误: 错误“NoneType”对象在文件中没有属性“strip”:\testdata\test2.pdf。
有什么想法吗?
【问题讨论】:
标签: python nonetype tika-server