Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to extract PDF Table data from Python

Shulou Source: shulou.com Published: 2022-06-02 07:18:03 12月01日 Update

How to extract PDF table data in Python, in view of this problem, this article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible method.

What is Camelot? according to the project description, Camelot is a Python tool for extracting tabular data from PDF files. Specifically, the user can open the PDF file like Pandas, then use this tool to extract the table data, and finally specify the form of the output (such as the csv file). The PDF file provided by the code sample project is shown in the figure, assuming that the user needs to extract the information in Table 2-1 between these words.

PDF file. We need to extract form 2-1. The code to extract table data using Camelot is as follows: > import camelot

>

> tables [0] .DF # get a pandas DataFrame!

> tables.export ('foo.csv', favored csvents, compress=True) # json, excel, html, sqlite, you can specify the output format

> tables [0] .to _ csv ('foo.csv') # to_json, to_excel, to_html, to_sqlite, export data as a file

> tables

> tables [0]

# get the format of the output

> > tables [0] .parsing _ report

{

'accuracy': 99.02

'12.24 whitespace':

'order': 1

'page': 1

}

The following is the result of the output. For merged cells, Camelot does blank line processing after extraction, which is a safe method. Installation methods the project author provides three installation methods. First of all, you can use Conda for installation, which is the easiest. Conda install-c conda-forge camelot-py

The most popular installation method is to use pip installation. Pip install camelot-py [cv]

You can also clone code from the project and install it using source code. Git clone https://www.github.com/camelot-dev/camelot

Cd camelot

Pip install ".cv]"

This is the answer to the question about how to extract PDF table data from Python. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel to learn more about it.

Tags: Tables files data methods projects outputs codes questions tools forms more formats users this is help answer easy safe easy easy between Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info Xiaomi MySQL Huawei OPPO Reno