VertiStratInsights Main website ↗

How to use vehicle_fuel_mileage: running cost per km for petrol, diesel, CNG and EV in India

Monday, October 19, 2026

A formula-driven Excel model and a real dataset of 303 certified car fuel-efficiency declarations for comparing petrol (E20), diesel, CNG and electric vehicles on cost per kilometre, six-city prices and tax.

Open-Source Tools · How-To · Energy & fuels models

How to use vehicle_fuel_mileage: running cost per km for petrol, diesel, CNG and EV in India

Skip to article content
Text Size

Revised · v1.0.0 · what changed

19tests passed in the demo
21 of 21built-in consistency checks reading PASS after recalculation
Rs 6.65 vs 2.97 vs 1.41hatchback cost per km in Delhi: petrol, CNG, EV
303ARAI-certified 4-wheeler declarations analysed

Code: github.com/herrrickshaw/vehicle_fuel_mileage

Watch the walkthrough

Watch on YouTube: youtu.be/TLlSUbHjzAM

Why it is useful

  • Car buyers, fleet managers and students can compare running costs across fuels with editable inputs instead of trusting a headline claim: choose a city, change the E20 mileage drop or usage, and the whole workbook reprices.
  • It replaces hand-built comparison spreadsheets with an auditable one: formula-driven, with 21 automated checks, and mileage assumptions calibrated on 303 real declarations rather than guesses.
  • Evidence from the run: 19 tests passed, the workbook built in 0.1 s, LibreOffice recalculation reported 0 errors, and the Checks sheet read ALL PASS.
  • The same data showed the E20 effect on an average petrol car: 16.67 kmpl falls to about 16.0 kmpl at a 4% drop.

What it is for

vehicle_fuel_mileage builds an 11-sheet Excel cost model (cities, cost per km, ethanol impact, total cost of ownership, tax structure, fleet sales, OMC price board, exchequer revenue) on a July 2026 price basis, plus a Word report builder and a script that extracts and analyses fuel-efficiency declarations from the SIAM PDF.

This post covers the model workbook and the declaration analysis. Prices are inputs in the workbook: update them to today's before drawing conclusions.

Who it is for

  • Vehicle buyers comparing petrol, diesel, CNG and EV running cost
  • Students and analysts studying fuel taxation and ethanol blending
  • Developers who want a worked example of a tested, formula-driven Excel build
Not for.
  • Investment advice: this is not investment advice
  • A purchase decision on its own: it covers running cost, not resale, insurance or availability of charging or CNG
  • Current prices: inputs are a July 2026 snapshot

What you need

RequirementWhyHow to get it
Python 3 with openpyxl, pandas, pdfplumber (pytest for tests)requirements.txt and requirements-dev.txtpip install -r requirements-dev.txt
LibreOffice (soffice)scripts/recalc.py recalculates the workbook formulas so values can be readbrew install --cask libreoffice, or from libreoffice.org; you can also open the .xlsx in Excel
Node.js (optional)Only the Word report builder (scripts/build_report.js) needs it; not run in this demonodejs.org
A terminal and gitTo clone and runTerminal on macOS/Linux, or Git Bash/WSL on Windows
No API keys or accountsAll inputs are in the repoNone needed

Get the code and an AI assistant

You do not have to be a programmer. Get the repository, give it to an AI assistant, and ask in plain language. Any of these routes works:

ToolWhat you needBest for
GitHubFree account to fork or star; git to clone, or the green Code button, then Download ZIP, or open in CodespacesGetting the code and keeping up with updates
Claude CodeClaude subscription or API key; run claude inside the cloned folderLetting the AI read and run the whole repo
Gemini CLIGoogle account; run gemini inside the cloned folderThe same hands-on workflow with Gemini
Claude.ai, Gemini or ChatGPT in the browserA chat account; upload README.md and the files you care about (or paste the output of git ls-files)Understanding the project and asking questions without installing anything
Other tools (Copilot Chat, Cursor, Codex CLI)Open the cloned folder in the tool and point it at README.md firstEditing and extending the code
git clone https://github.com/herrrickshaw/vehicle_fuel_mileage.git
cd vehicle_fuel_mileage
claude      # or: gemini

Install

  1. Clone and enter the repo
    git clone https://github.com/herrrickshaw/vehicle_fuel_mileage.git
    cd vehicle_fuel_mileage
  2. Create a virtual environment and install dependencies
    python3 -m venv .venv && source .venv/bin/activate
    pip install -r requirements-dev.txt

Quick start: commands and what you should see

Run the tests

python -m pytest -q

19 passed in about 1.5 seconds.

Analyse the 303 fuel-efficiency declarations

python scripts/analyze_fe_declarations.py

A fuel-type summary table, the petrol-to-CNG uplift, and the E20 mileage haircut.

Build the Excel model, then recalculate it

python scripts/build_model.py
python scripts/recalc.py outputs/EV_CNG_Diesel_Ethanol_Vehicle_Cost_Model.xlsx

A saved workbook with 11 sheets, then JSON reporting status success and 0 errors. Open the CostPerKm sheet.

Sample outputs

Real output from a run on the date shown in the sources line; trimmed to fit.

Fuel-efficiency declarations by fuel type (analyze_fe_declarations.py, run 19 Oct 2026)

python scripts/analyze_fe_declarations.py
Gasoline         n=188  mean FE  16.67  mean CO2 152.2
Diesel           n= 95  mean FE  17.91  mean CO2 153.6
CNG              n= 11  mean FE  27.40  mean CO2 102.1
Gasoline Hybrid  n=  8  mean FE  21.94  mean CO2 116.6

Same-model petrol->CNG mean distance uplift: +40.3%  (11 nameplates)
Mean petrol declared FE 16.67 kmpl -> E20@4% 16.0 kmpl (-0.67)

Fuel efficiency is km per litre (petrol, diesel), km per kg (CNG). Hybrid and electric rows are small samples.

Cost per km, Delhi prices (CostPerKm sheet after recalculation, Rs per km)

open the CostPerKm sheet
Vehicle        Petrol(E20)  Diesel  CNG   EV
Hatchback      6.65         -       2.97  1.41
Sedan          7.09         4.33    3.20  1.51
Compact SUV    8.18         5.01    3.78  1.63
Two-wheeler    1.93         -       0.81  0.35

Inputs: petrol Rs 102.12/L, diesel Rs 95.20/L, CNG Rs 83.09/kg, electricity Rs 10.6/kWh blended

Petrol cost already includes the selected 4% E20 mileage drop.

Hatchback cost per km across six cities (Cities sheet, Rs per km)

open the Cities sheet
City       Petrol  CNG   EV
Delhi      6.65    2.97  1.41
Mumbai     7.24    3.07  1.73
Kolkata    7.39    3.34  1.52
Chennai    7.02    3.46  1.41
Bengaluru  7.27    3.46  1.52
Hyderabad  7.53    3.46  1.57

Diesel per km is shown in the sheet for the compact SUV only.

Built-in consistency checks

open the Checks sheet
21 individual checks, all PASS
Overall: ALL PASS

Read after LibreOffice recalculation reported total_errors: 0.

Ways to use it

MethodHow it works
Excel workbookOpen the built .xlsx, choose a city and edit blue input cells (prices, E20 drop, usage); everything recalculates.
Python scriptsRun build_model.py to regenerate the workbook and analyze_fe_declarations.py for the dataset analysis.
CSV dataUse data/siam_bsvi_fe_2020_4w.csv (303 rows) directly in your own analysis.
Through an AI assistantOpen the cloned folder in Claude Code or Gemini CLI and ask it to change a price or compare two cities, or upload README.md and the CSV to a chat assistant.

Sample prompts for your AI assistant

Copy, paste and edit the parts in [brackets].

  • Explain this repository in plain English: what does the Excel model compare and where do its mileage numbers come from?
  • Run the tests and the declaration analysis, then summarise petrol, diesel and CNG efficiency in a small table.
  • Update the Delhi petrol, diesel and CNG prices in the model to [current prices] and tell me which fuel is cheapest per km for a hatchback.
  • How many km a year would I need to drive for an EV [price premium in rupees] to pay back versus a petrol car? Use the TCO_Scenarios logic.
  • Read data/sources.md and list which assumptions are sourced and which are estimates.

Limits and honest caveats

  • Not investment advice. Running cost only.
  • Fuel and electricity prices are a July 2026 snapshot (Delhi petrol Rs 102.12/L in the model); update them before using results.
  • The built workbook has no cached values until recalculated; I recalculated with LibreOffice (soffice) to read the numbers shown. Open in Excel or run scripts/recalc.py.
  • The SIAM declaration dataset is from passenger vehicles as on 1 April 2020; it has only 11 CNG, 8 hybrid and 1 electric entries, so those means are thin.
  • Two-wheeler CNG (102 km/kg) in the CostPerKm sheet is a modelling assumption for comparison, not a product widely sold; treat it with caution.
  • State VAT rates are indicative effective rates; several states add per-litre cesses.
  • I did not run the Word report builder (Node).

Sources: the vehicle_fuel_mileage README, scripts and tests; pytest, analyze_fe_declarations.py, build_model.py and recalc.py run on 19 October 2026 on a fresh clone.

Revision history.
  • v1.0.0 — 19 October 2026 — first published.

About this article: Researched, written and edited by Umashankar Triplicane Dwarakanathan, with AI research assistance; every figure is meant to trace to the primary source cited. See the Editorial Policy for how sourcing, AI use and corrections work.

Umashankar Triplicane Dwarakanathan
Contact Us
Umashankar Triplicane Dwarakanathan
Investment Promotion & Energy-Sector Leader · Chennai, Tamil Nadu, India
LinkedIn → GitHub → Email +91 78273 81696
How this site works

Data-led analysis of India's trade, currency and industrial policy. Every article is built from primary official sources, and every figure links back to the release, table or filing it came from.

Sources. DGCI&S TradeStat (imports/exports, HSN-wise) · PIB (government press releases, January 2017 to today, refreshed daily) · RBI (circulars, balance of payments) · MoSPI (CPI/WPI, IIP) · PARIVESH (environmental clearances) · CCIL (bond yields) · BIS (policy rates) · SEBI, NSE/BSE and SEC filings for company data.

Interpretation. Figures carry their vintage and retrieval date; estimates and press-reported numbers are labelled as such; where sources disagree, both are shown. Corrections are made visibly, never silently. Articles are written with AI assistance from the cited sources — AI-generated text can misstate figures even when working from real material, so verify any number that matters to a decision against the linked primary source.

footer

Browse all articles by topic

Every piece on this blog, grouped. Or read the full index.

Agriculture & FertilisersAI ToolsChemicalsClimate & CarbonEnergy & FuelsGas & LNGImport SubstitutionIndustrial PolicyMarkets & FinanceMobility & EVPrices & InflationTextilesTrade & Tariffs

Each topic is a live archive page that updates itself as pieces are labelled. It replaces a hand-kept list that had fallen 18 articles behind.