Skip to main content

PDF to CSV Converter

Package version Supported Python versions codecov License Stars Issues

This project provides a tool to convert tables from PDF files into CSV or XLSX format using the Docling library. It extracts tables from PDFs and saves them as CSV or XLSX files, optionally reversing text for right-to-left languages.

How It Works

  1. PDF Input: Provide the path to the PDF file you want to convert.
  2. Table Extraction: The tool uses Docling's DocumentConverter to extract tables from the PDF.
  3. DataFrame Conversion: Each extracted table is converted into a pandas DataFrame.
  4. Optional Text Reversal: If the rtl option is enabled, text in the DataFrame is reversed.
  5. 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

Metadata

Release files for pdf2csv 0.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pdf2csv 0.2.2
File Size Uploaded
pdf2csv-0.2.2.tar.gz 6.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pdf2csv 0.2.2
File Interpreter ABI Platform
pdf2csv-0.2.2-py3-none-any.whl Python 3 none any Details

Total release size: 13.4 kB

Release files / pdf2csv-0.2.2.tar.gz

Download URL pdf2csv-0.2.2.tar.gz
Size 6.2 kB
Tags Source
SHA-256 checksum
How to use checksums
7e32fae06dc26409f97bc1e32febf08fcc1e8d2076462bb228a7d133e4b5af42
BLAKE2b-256 checksum
How to use checksums
ee5685489f3d876d226e956239c66ac9cad40ec581fcaf7324b98be03fad7a20
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.4.18

Release files / pdf2csv-0.2.2-py3-none-any.whl

Download URL pdf2csv-0.2.2-py3-none-any.whl
Size 7.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a95ec04f521773ff746e3b3e323486c692455708a6b246c5d42862df8cc9b2a7
BLAKE2b-256 checksum
How to use checksums
13a43630587e6457ab6a7da432229476702d88c27bff8bd3dafb2a2cc18f9f06
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.4.18

Release history Release notifications | RSS feed

This release

0.2.2 This release

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page