Lightweight OCR slip processing tool for extracting data from Krungthai slips in images and exporting the results to CSV or optionally XLSX.
ReadSlip is a Python-based OCR (Optical Character Recognition) tool that processes Krungthai bank slip images from JPG-format or JPEG-format images from one or more file(s) or directory(ies). It extracts key data fields, structures them into a table (Pandas DataFrame), and exports to a .csv file by default. Optionally, you can export to .xlsx
- Supports Krungthai slip format only (bank slip template/layout)
- Processes JPG / JPEG image files
- Recognizes both Thai and English text
- Default export format:
.csv - Optional export format:
.xlsx
- Python 3.x
pip
- Clone the repository:
$ git clone https://github.com/Shivalux/readslips.git
$ cd readslips- (Optional but recommended) Create and activate a virtual environment:
# MacOS / Linux
$ python3 -m venv <virturl_environment_name>
$ source <virturl_environment_name>/bin/activate
# Window
$ python -m venv <virturl_environment_path>
$ .\venv\Scripts\activate- Install dependencies:
# MacOS / Linux
$ pip3 install -r requirments.txt
# Window
$ pip install -r requirments.txt- Update the shebang (first line) in
readslipscript to point to your Python interpreter path, e.g.:
#!./venv/bin/python3 <---- update this line.
import easyocr
import argparse
import os
import cv2
...You can find the correct path via:
$ which python3 # MacOS/Linux
$ where python # Window- (If you activated virtual environment) deactivate when done:
$ deactivatereadslips [-h] [-v] [-x] [-f FILE_NAME] [-o FILE_NAME] [-a FILE_NAME] [PATHS ...][PATHS...] One or more file paths or directories containing slip images.
| Option | Description |
|---|---|
-h, --help |
Show this help message and exit |
-v, --version |
Show the current version of the program and exit |
-x, --xlsx |
Export the result as an .xlsx file. When the --filename option is specified, this option will be ignored |
-f FILE_NAME, --filename FILE_NAME |
Specify the name of the output file to export results |
-o FILE_NAME, --open FILE_NAME |
Specify a file to open and load existing data |
-a FILE_NAME, --append FILE_NAME |
Append new data to an existing file |
- if
--filenameoption is given, the--xlsxoption will be ignored. - if
--appendoption is used, the option--openand--filenameare ignored to avoid conflicts.
- Images of Krungthai bank slips in
JPGorJPEGformat. - One or more file paths or directories.
- Default:
.csvfile with structured data extracted from the slips. - Optional:
.xlsxfile if --xlsx flag used (and not overridden). - Output fields may include: date, time, amount, company, noted, filename(hyperlink).
$ ./readslips -x -f slips_data .- Processes all
.jpg/.jpegimages insidecurrent directory. - Recognise text from each image.
- Exports the extracted data into slips_data.xlsx.
date,time,amount,company,noted,filename
05/08/2568,15:42,"1,000.00",AI,EasyPass,"=HYPERLINK(""file:///Users/shivarakii/Documents/payment_orc/slip_sample.jpg"", ""slip_sample.jpg"")"Created by @Shivalux
This project is licensed under the MIT License.
See the LICENSE file for more information.