GrabFood Expense Tracker for Google Sheets
Tired of manually tracking your GrabFood expenses? This script automates the entire process by connecting to your Gmail, parsing e-receipts, and logging every detail directly into a Google Sheet.
Designed for Google Colab, it leverages native secret management to keep your credentials safe and encrypted.
Ready to get started? Grab the Google Colab Notebook and follow the setup guide below.
🚀 Key Features
Section titled “🚀 Key Features”- Monthly Batching: Fetches data in monthly chunks to avoid connection timeouts with Gmail’s IMAP server.
- Deep Parsing: Uses BeautifulSoup4 to navigate complex HTML email structures, ensuring accurate data extraction.
- Deduplication: Fingerprints each receipt (Date + Restaurant) to prevent duplicate entries if the script is re-run.
- Financial Breakdown: Separates the subtotal, delivery fee, order fee, packaging, and promos for easy budgeting.
🛠️ Setup & Requirements
Section titled “🛠️ Setup & Requirements”1. Google Account Security (App Password)
Section titled “1. Google Account Security (App Password)”To connect to Gmail via IMAP, you’ll need an App Password. Standard passwords won’t work if you have 2-Step Verification enabled.
- Go to your Google Account Security Settings.
- Search for “App Passwords”.
- Create a new app named
GrabFood Tracker. - Copy the 16-character code. You’ll need it in a later step.
2. Google Sheets Configuration
Section titled “2. Google Sheets Configuration”- Create a new Google Sheet.
- Get your Spreadsheet ID from the URL:
docs.google.com/spreadsheets/d/[YOUR_ID_HERE]/edit - The script will automatically create the header row if the sheet is empty.
3. Colab Secrets Management
Section titled “3. Colab Secrets Management”To keep your credentials secure, use Colab’s secret management:
- Open the Google Colab Notebook.
- Click the Key icon (Secrets) on the left sidebar.
- Add the following secrets:
EMAIL_USER: Your full Gmail address.APP_PASSWORD: The 16-character code from Step 1.
- Ensure the “Notebook access” toggle is turned ON for both.
📋 Data Structure
Section titled “📋 Data Structure”The script populates the following columns in your Google Sheet:
| Column | Description |
|---|---|
| Date & Exact Time | Formatted as M/D/YYYY HH:MM:SS |
| Restaurant Name | The store you ordered from |
| Restaurant Address | Physical address of the restaurant |
| Items Ordered | Quantity and Name (e.g., 2x Nasi Goreng) |
| Driver | Name of the delivery partner |
| Delivery Address | Your delivery destination tag (e.g., “Home”) |
| Subtotal | Price of food before fees |
| Delivery | Shipping/Delivery cost |
| Order Fee | Grab service fee |
| Packaging | Restaurant packaging charge |
| Promo | Total discount applied (expressed as a negative number) |
| Total | Final amount paid |
🏃 How to Run
Section titled “🏃 How to Run”- Open the Google Colab Notebook.
- Update the
SPREADSHEET_IDvariable with your ID. - Adjust the
start_dateandend_dateto define your lookup window. - Run the cell. You’ll be prompted to authorize the Google Sheets API.
⚠️ Safety Note
Section titled “⚠️ Safety Note”This script only uses your credentials to establish a local connection between the Google Colab environment and Gmail’s IMAP server. No data is transmitted to third parties. Always keep your APP_PASSWORD secret.
📊 Sample output
Section titled “📊 Sample output”| Date & Exact Time | Restaurant Name | Restaurant Address | Items Ordered | Driver | Delivery Address | Subtotal | Delivery | Order Fee | Packaging | Promo | Total |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 1/12/2024 18:08:00 | Bakpao GaGa Kawangkoan - Apartment Gading Nias | Apartement Gading Nias | 1x 6 Bakpao Babi | Riduan Syahputra | Home | 75600 | 17000 | 3000 | - | -34900 | 60700 |
| 1/20/2024 8:00:00 | Nasi Uduk Hajiten 999 - Rawamangun | Jl. H. Ten Raya No. 83 ( Samping Warteg Leman ), | 2x Nasi Uduk Telor Dadar, 2x Bakwan Sayuran, 2x Tahu Isi | Sopyan | Home | 44000 | 12000 | 3000 | - | -16400 | 42600 |
| 1/21/2024 10:48:00 | Ayam Koplo (Nasi Geprek) - Gading | Jl. Gading Putih Raya, No.99 (Sebelah Dr.Soetomo), | 1x 5 Nasi Wangi Penyet Sambel Nusantara | ABDUL AJID | Home | 125001 | 13000 | 3000 | 2500 | -44250 | 99251 |