Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x 用python从PDF中提取嵌入文件_Python 3.x_Pdf - Fatal编程技术网

Python 3.x 用python从PDF中提取嵌入文件

Python 3.x 用python从PDF中提取嵌入文件,python-3.x,pdf,Python 3.x,Pdf,见图 我一直在尝试使用pyPDF2从PDF文档中提取一个嵌入的csv文件,但我不理解PDF,似乎无法得到有用的错误响应 尝试使用流方法、大纲方法、缓存。。。没什么 如何提取CSV文件 谢谢 尝试将数据(CSV数据)从pdf复制粘贴(手动)到记事本,并以“.CSV”格式保存,然后使用pandas.read\u CSV读取文件! 试试这个,让我知道它是否有效 #This module contains all the functions for working with PDF documents.

见图

我一直在尝试使用pyPDF2从PDF文档中提取一个嵌入的csv文件,但我不理解PDF,似乎无法得到有用的错误响应

尝试使用流方法、大纲方法、缓存。。。没什么

如何提取CSV文件

谢谢

尝试将数据(CSV数据)从pdf复制粘贴(手动)到记事本,并以“.CSV”格式保存,然后使用pandas.read\u CSV读取文件! 试试这个,让我知道它是否有效

#This module contains all the functions for working with PDF documents.
import PyPDF2 as pf  

# Step 1 Read pdf into a variable
pdf = pf.PdfFileReader('*your file location*')  

# Step 2 "The process of traversing the PDF tree structure"

catalog = pdf.trailer['/Root']  
fDetail = catalog['/Names']['/EmbeddedFiles']['/Names']  
soup = fDetail[1].getObject()  

# Step 3 Stream data to a variable for further use
file = soup['/EF']['/F'].getData()
关于这两个资源,可以找到更多信息

感谢您的回复。手动执行确实有效,但我正在自动化进程,因此使用Python标记。还发现了一个名为Xpdf的工具,这是一个从命令提示符运行的命令提示符可执行文件,可以从.bat文件自动触发。