A python library and CLI tool to convert PDF files to CSV files.
Project description
PDF to CSV Converter
How It Works
- PDF Input: Provide the path to the PDF file you want to convert.
- Table Extraction: The tool uses Docling's
DocumentConverterto extract tables from the PDF. - DataFrame Conversion: Each extracted table is converted into a pandas DataFrame.
- Optional Text Reversal: If the
rtloption is enabled, text in the DataFrame is reversed. - CSV/XLSX Output: The DataFrames are saved as CSV or XLSX files in the specified output directory.
Dependencies
This project heavily depends on the Docling library for PDF table extraction.
CLI Usage
You can use the CLI tool to convert PDF files to CSV or XLSX:
pdf2csv convert-cli <pdf_path> --output-dir <output_dir> --output-format <csv|xlsx> --rtl --verbose
Example:
pdf2csv convert-cli example.pdf --output-dir ./output --output-format xlsx --rtl --verbose
With uvx
You can use the CLI tool with uvx:
uvx pdf2csv convert-cli <pdf_path> --output-dir <output_dir> --output-format <csv|xlsx> --rtl --verbose
Example:
uvx pdf2csv convert-cli example.pdf --output-dir ./output --output-format xlsx --rtl --verbose
Python Usage
You can also use the converter directly in your Python code:
from pdf2csv.converter import convert
pdf_path = "example.pdf"
output_dir = "./output"
rtl = True
output_format = "xlsx"
dfs = convert(pdf_path, output_dir=output_dir, rtl=rtl, output_format=output_format)
for df in dfs:
print(df)
TODO:
- Convert datatype to numeric
- Support for XLSX output
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pdf2csv-0.2.0.tar.gz.
File metadata
- Download URL: pdf2csv-0.2.0.tar.gz
- Upload date:
- Size: 5.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.4.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
42815a2679bb239e191929e83d497eaa84a442f00d0218d9b6d2f29d14935d53
|
|
| MD5 |
9b136a70c3e877adf11a5117fa17cb4f
|
|
| BLAKE2b-256 |
9c64185389fd934cd2bbeee57100475e42dec5d97f89623363daabce3b91d9f1
|
File details
Details for the file pdf2csv-0.2.0-py3-none-any.whl.
File metadata
- Download URL: pdf2csv-0.2.0-py3-none-any.whl
- Upload date:
- Size: 6.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.4.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e451c30f15837f323aff9d10d77cb398d74e3e224910140f9f61b59736061e85
|
|
| MD5 |
82167ba372d3191c44a35e09cc202abc
|
|
| BLAKE2b-256 |
89ee32f005fe2a3b9f936093cd15c695edb0797308bd2a5f48d18e7c0c673aa6
|