Skip to content

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.


  • 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.

To connect to Gmail via IMAP, you’ll need an App Password. Standard passwords won’t work if you have 2-Step Verification enabled.

  1. Go to your Google Account Security Settings.
  2. Search for “App Passwords”.
  3. Create a new app named GrabFood Tracker.
  4. Copy the 16-character code. You’ll need it in a later step.
  1. Create a new Google Sheet.
  2. Get your Spreadsheet ID from the URL: docs.google.com/spreadsheets/d/[YOUR_ID_HERE]/edit
  3. The script will automatically create the header row if the sheet is empty.

To keep your credentials secure, use Colab’s secret management:

  1. Open the Google Colab Notebook.
  2. Click the Key icon (Secrets) on the left sidebar.
  3. Add the following secrets:
    • EMAIL_USER: Your full Gmail address.
    • APP_PASSWORD: The 16-character code from Step 1.
  4. Ensure the “Notebook access” toggle is turned ON for both.

The script populates the following columns in your Google Sheet:

ColumnDescription
Date & Exact TimeFormatted as M/D/YYYY HH:MM:SS
Restaurant NameThe store you ordered from
Restaurant AddressPhysical address of the restaurant
Items OrderedQuantity and Name (e.g., 2x Nasi Goreng)
DriverName of the delivery partner
Delivery AddressYour delivery destination tag (e.g., “Home”)
SubtotalPrice of food before fees
DeliveryShipping/Delivery cost
Order FeeGrab service fee
PackagingRestaurant packaging charge
PromoTotal discount applied (expressed as a negative number)
TotalFinal amount paid

  1. Open the Google Colab Notebook.
  2. Update the SPREADSHEET_ID variable with your ID.
  3. Adjust the start_date and end_date to define your lookup window.
  4. Run the cell. You’ll be prompted to authorize the Google Sheets API.

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.


Date & Exact TimeRestaurant NameRestaurant AddressItems OrderedDriverDelivery AddressSubtotalDeliveryOrder FeePackagingPromoTotal
1/12/2024 18:08:00Bakpao GaGa Kawangkoan - Apartment Gading NiasApartement Gading Nias1x 6 Bakpao BabiRiduan SyahputraHome75600170003000--3490060700
1/20/2024 8:00:00Nasi Uduk Hajiten 999 - RawamangunJl. H. Ten Raya No. 83 ( Samping Warteg Leman ),2x Nasi Uduk Telor Dadar, 2x Bakwan Sayuran, 2x Tahu IsiSopyanHome44000120003000--1640042600
1/21/2024 10:48:00Ayam Koplo (Nasi Geprek) - GadingJl. Gading Putih Raya, No.99 (Sebelah Dr.Soetomo),1x 5 Nasi Wangi Penyet Sambel NusantaraABDUL AJIDHome1250011300030002500-4425099251