【发布时间】:2020-10-08 09:59:39
【问题描述】:
我正在从 pdf(使用 python)中提取文本以分析它们,因此我经常处理科学论文。我正在使用 pdfplumber,它运行良好,唯一的问题是此类 pdf 通常包含 columns,我还没有找到让我的算法识别这一点的方法。 p>
我的代码是:
text = ""
with pdfplumber.open(r'example.pdf') as pdf:
pages = pdf.pages
for i, pg in enumerate(pages):
text = text + " " + pages[i].extract_text(x_tolerance = 1)
text = text.replace('\n',' ')
text = text.replace('\r',' ')
text = text.replace('\no',' ')
text = text.replace('\nD',' ')
text = text.lower()
text = re.sub(r'[^a-zA-Z0-9\s]', ' ', text)
你知道一个可能对我有帮助的函数吗?谢谢!
【问题讨论】:
-
问题解决了吗?你能更新一下状态吗
标签: python multiple-columns text-extraction