A Python tool that converts PDF and image files (JPG, PNG) to CSV format using OCR (Optical Character Recognition). This tool is particularly useful for extracting tabular data from documents and images.
- Convert PDF files to CSV
- Convert image files (JPG, PNG) to CSV
- Automatic table detection and extraction
- Image enhancement for better OCR results
- Support for multi-page PDFs
- Clean and organized output in CSV format
- Python 3.8 or higher
- Tesseract OCR installed on your system
brew install tesseract
sudo apt-get update
sudo apt-get install tesseract-ocr
- Download the installer from UB Mannheim
- Run the installer
- Add Tesseract to your system PATH
- Clone the repository:
git clone https://github.com/yourusername/image-to-csv.git
cd image-to-csv
- Create and activate a virtual environment:
python -m venv .venv
source .venv/bin/activate # On Unix/macOS
# or
.venv\Scripts\activate # On Windows
- Install dependencies:
pip install -e .
- Place your PDF or image files in the
input
directory - Run the converter:
python -m image_to_csv
- Find the converted CSV files in the
output
directory
- For PDFs:
{original_name}_page{page_number}.csv
- For images:
{original_name}.csv
-
PDF Processing:
- Converts PDF pages to images
- Enhances image quality for better OCR
- Performs OCR on each page
- Detects and extracts tabular data
- Saves each page as a separate CSV file
-
Image Processing:
- Enhances image quality
- Performs OCR
- Detects and extracts tabular data
- Saves as CSV file
image-to-csv/
├── input/ # Input directory for PDF and image files
├── output/ # Output directory for CSV files
├── image_to_csv/ # Source code
│ ├── __init__.py
│ ├── __main__.py
│ └── converter.py
├── pyproject.toml # Project configuration
└── README.md # This file
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.