A Python-based tool to automatically detect, extract, and convert tables from images into structured JSON and Excel formats using image processing techniques.
- Automatic Grid Detection: Automatically identifies rows and columns based on horizontal and vertical lines.
- Visual Cropping: Crops image regions based on the detected table grid.
- Dual Output: Exports extracted data into both structured JSON and standard Excel (XLSX) formats.
Clone the repository and install the required dependencies:
git clone https://github.com/bimbim-byte/image-table-parser.git
cd image-table-parser
pip install -r requirements.txtBefore running the program, you need to configure the settings in config.py. Here are the key parameters you can adjust:
# Path to your input image and output directory
IMAGE_PATH = "data_test/test1.jpg"
# Sensitivity adjustments for grid detection
HORIZONTAL_PERCENT = 0.85
VERTICAL_PERCENT = 0.85
LINE_GAP = 2
MARGIN = 2💡 Tip: If your table has blurry or dashed lines, try lowering the HORIZONTAL_PERCENT / VERTICAL_PERCENT and increasing the LINE_GAP.
- Open config.py and set your IMAGE_PATH and OUTPUT_DIR.
- Adjust the detection sensitivity parameters if necessary.
- Run the main script:
python main.py
Once the execution is complete, the OUTPUT_DIR will contain:
- Cropped Images: Visual segments of the table rows and columns.
- JSON File: Structured OCR data representing the table content.
- Excel File (.xlsx): Ready-to-use spreadsheet mapped from the image table.
- Table-Only: This program is specifically designed for structured images that contain clear tables. It may not yield accurate results on standard unstructured text documents.
- Configuration Check: Ensure that
config.pypoints to a valid image path before executingmain.py.