This is a little script that passes a list of receipts in google drive to chatGPT in order to extract information like total gross amount, total net amount, total vat, date, company and description.
The resulting google sheet is a table with all values listed and a link to the original image for you to double-check. Empty values are marked red. Basic aggregation statistics are saved in a second worksheet.
Manual re-check is necessary, but simplified by the link to the original image.
- Follow the instructions for setting up a project and creating an OAuth 2.0 Client ID.
- Make sure that you enable ['https://www.googleapis.com/auth/spreadsheets', 'https://www.googleapis.com/auth/drive']
- Download the credentials, rename them to
credentials.jsonand put them in the project root. - Get OpaneAI API key and put it .env file. See .env.example for reference.
The receipts should either be imgages or pdfs. If a receipt is in multiple files, you can name them like {data_name}_1.jpg, {data_name}_2.jpg.
PDFs are transformed into images using pdf2image utilizing this naming scheme for multiple pages. Make sure you have installed poppler (see docs).
The Folder root that you use to call the cli, assumes to have sub-folders (e.g. for each month, name is irrelevant). In those folders are the actual receipts stored.
For each sub-folder a single spreadsheet is generated.
The structure should look like this:
root
│-- 2021-01
│ │-- receipt_1.jpg
│ │-- receipt_2.jpg
│-- 2021-02
│ │-- receipt_1.jpg
│ │-- receipt_2.pdf
- Install the requirements with
pip install -r requirements.txt - Run the script with
python -m receipt_parser --folder_id <your_folder_id>. The folder ID of the google drive folder can be found in the URL. - The script will create a google sheet for each month and fill it with the extracted information.
