问题标签 [pdf-scraping]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
251 浏览

r - 在 r 中使用 dplyr 将纯文本转换为数据框

我正在尝试使用 r 将使用 pdftools 和 tidyverse 从 pdf 中抓取的纯文本转换为数据框。我希望使用 tidyverse 包的解决方案。我使用以下代码获取包含我的基本信息的字符串列表:

这会产生以下格式的 26 个字符串列表的列表:

请注意子列表第 1 行和第 3 行开头的状态名称以及变量名称中的空格。每个状态应该是一行。应该有 6 列变量 1 变量 2 变量 3 变量 4 变量 5 变量 6 以及相应的值。

有关如何构建此表的任何解决方案?

0 投票
1 回答
1884 浏览

python-3.x - KeyError:'/内容'

当尝试使用 PyPDF2 从 pdf 中获取数字时,我得到:

KeyError:'/内容'。这是代码:

该代码适用于其他 pdf 文件,这是回溯:

0 投票
1 回答
40 浏览

python - Pandas DataFrame 组合多行跨列

我有一个复杂的抓取数据框,如下所示:

在此处输入图像描述

对于上下文,PDF 中的原始数据如下所示:

在此处输入图像描述

数据框信息:

我希望数据看起来像下图。列( ) 中的每一行都应将列( ) 行连接在一起,直到下一个S或出现在列中:P1Transaction Type0AssetSP1
在此处输入图像描述

我该怎么做?

0 投票
1 回答
852 浏览

r - 在 tabulizer 包中使用 extract_tables() 函数时遇到问题:

我正在尝试从 PDF 但从我的本地目录而不是从网络浏览器中抓取表格(因为它没有直接打开到浏览器中)。然而,我将 pdf 下载到我的本地目录并尝试从那里只读取我的表格!

当我运行我的代码时:

我收到以下错误,我在互联网上的任何地方都找不到:

有没有办法解决这个问题?

.pdf我正在尝试抓取的内容已从该网站下载到我的计算机上。
该报告有标题ICNARC COVID-19 report 2020-05-29.pdf,可以使用页面右侧的链接下载。

以下是traceback()我收到错误消息后的输出。

sessionInfo()返回:

提前感谢您的帮助!

0 投票
2 回答
60 浏览

regex - Regular expression to remove first occurrence of letters in a determined order

I am trying to scrape a pdf with tables using python and the tabula package. In some cases, two columns are being extracted completely mixed up. I know that the column "Type" Should only have these two values: EE-Male or EE-Female. Thus, I need to remove all the extra letters in column "Type" and put them at the end of column "Name" in the exact order that they appear.

As a result I would need to have these two columns:

Any suggestion? Thanks!

0 投票
1 回答
750 浏览

python - 按行而不是按列从 pdf 文件中读取表格

我正在尝试从 PDF 文件中提取所有文本。我正在使用在线 PDF,它们包括表格。但是,此代码有效,当它到达 PDF 中的表格时,表格中的文本按列而不是按行打印,这会弄乱我的数据。有没有办法让表格按行读取,而不必单独浏览表格?我仍然需要 PDF 中的所有文本一起打印。我正在使用python。

0 投票
2 回答
74 浏览

r - 从刮掉的 pdf 中创建列,并在空格上进行切割

我正在尝试从以下 PDF 创建数据框

但是,当我调用它时,tab1它只有一列:

我想提取应该是创建数据框的各个列(例如,对于第 7 行,我将其内容提取到以下列中: 设施(“Adirondack”)已恢复(0)已故(0)正(0)待定(75 ) 负数 (0) )。我认为最有效的方法是根据空格在 tab1 中进行切割,但这不起作用,因为某些设施中有多个单词,所以空间切割会搞砸。有没有人有解决方案的想法?谢谢您的帮助!

0 投票
0 回答
92 浏览

python - How to extract a table from any file using python?

I'm writing a python program to extract tables from excel sheets and pdf. Currently, I'm using different libraries for each file type. Xlrd for excel sheets, Pdfminer for pdf.

I'm wondering if there is a generic approach to extract tables from any type of file (xls, pdf, csv, word etc.). Since I'm planning to expand the list of supported file types, writing different functions for each file type would be cumbersome.

P.S. I came across PETL while looking for solutions. I could not find any excel/pdf extraction examples and I could not fully understand the documentation. Would PETL fulfill my requirement? If yes, I would really appreciate an example. Thank you.

0 投票
1 回答
101 浏览

python - 如何在python中从多个PDF中返回所有提取的文本?

这是我的代码。到目前为止,它会将 pdf 的所有内容打印到 pages 变量中。但是,我似乎无法返回相同的提取文本。我一直在通过从随机 pdf 中提取信息并将其放在我正在调用的文件夹中来测试它。如何让它以与打印相同的方式返回提取的文本?

0 投票
3 回答
1333 浏览

python - 是否可以从 PDF 中提取具有格式的特定表格?

我正在尝试从 pdf 中提取特定表格,pdf 如下图所示

在此处输入图像描述

我尝试在 python 上使用不同的库,

使用 tabula-py

使用 PyPDF2

即使有文本和美丽的汤,我面临的问题是输出格式一团糟,有没有办法用更好的格式提取这个表?