🔧 AI Nachrichten GitHub Release: openai/codex vrust-v0.155.0-alpha.3.5 (11.09.2026)(11.09.2026 um 07:07 Uhr)
🔧 AI Nachrichten GitHub Release: openai/codex vrust-v0.155.0-alpha.3.6 (11.09.2026)(11.09.2026 um 08:08 Uhr)
🔧 AI Nachrichten GitHub Release: openai/codex vrust-v0.155.0-alpha.3.7 (11.09.2026)(11.09.2026 um 10:17 Uhr)
🔧 AI Nachrichten GitHub Release: openai/codex vrust-v0.155.0-alpha.3.8 (11.09.2026)(11.09.2026 um 12:30 Uhr)
🔧 AI Nachrichten GitHub Release: openai/codex vrust-v0.155.0-alpha.3.9 (11.09.2026)(11.09.2026 um 14:01 Uhr)
🔧 AI Nachrichten GitHub Release: openai/codex vrust-v0.155.0-alpha.3.10 (11.09.2026)(11.09.2026 um 17:56 Uhr)
🔧 AI Nachrichten GitHub Release: openai/codex vrust-v0.155.0-alpha.4 (14.09.2026)(14.09.2026 um 13:49 Uhr)
🔧 AI Nachrichten GitHub Release: openai/codex vrust-v0.155.0-alpha.2.4 (15.09.2026)(15.09.2026 um 01:05 Uhr)
🔧 AI Nachrichten GitHub Release: openai/codex vrust-v0.155.0-alpha.5 (15.09.2026)(15.09.2026 um 02:33 Uhr)
🔧 AI Nachrichten GitHub Release: openai/codex vrust-v0.155.0-alpha.6 (15.09.2026)(15.09.2026 um 04:02 Uhr)
🔧 AI Nachrichten GitHub Release: openai/codex vrust-v0.155.0-alpha.3.5 (11.09.2026)(11.09.2026 um 07:07 Uhr)
🔧 AI Nachrichten GitHub Release: openai/codex vrust-v0.155.0-alpha.3.6 (11.09.2026)(11.09.2026 um 08:08 Uhr)
🔧 AI Nachrichten GitHub Release: openai/codex vrust-v0.155.0-alpha.3.7 (11.09.2026)(11.09.2026 um 10:17 Uhr)
🔧 AI Nachrichten GitHub Release: openai/codex vrust-v0.155.0-alpha.3.8 (11.09.2026)(11.09.2026 um 12:30 Uhr)
🔧 AI Nachrichten GitHub Release: openai/codex vrust-v0.155.0-alpha.3.9 (11.09.2026)(11.09.2026 um 14:01 Uhr)
🔧 AI Nachrichten GitHub Release: openai/codex vrust-v0.155.0-alpha.3.10 (11.09.2026)(11.09.2026 um 17:56 Uhr)
🔧 AI Nachrichten GitHub Release: openai/codex vrust-v0.155.0-alpha.4 (14.09.2026)(14.09.2026 um 13:49 Uhr)
🔧 AI Nachrichten GitHub Release: openai/codex vrust-v0.155.0-alpha.2.4 (15.09.2026)(15.09.2026 um 01:05 Uhr)
🔧 AI Nachrichten GitHub Release: openai/codex vrust-v0.155.0-alpha.5 (15.09.2026)(15.09.2026 um 02:33 Uhr)
🔧 AI Nachrichten GitHub Release: openai/codex vrust-v0.155.0-alpha.6 (15.09.2026)(15.09.2026 um 04:02 Uhr)

🔧 Programmierung 🕛 vor 2 Monaten 5 Min Lesezeit
0

Build a GST Invoice Parser in 70 Lines of Python

↗ Quelle (dev.to)
🗣️ Stimme:
📑 Inhaltsübersicht

If you run a small business in India, you know the monthly ritual: a folder full of vendor invoice PDFs, and a spreadsheet that needs GSTIN, invoice number, date, taxable value, and GST amounts pulled out of every single one. Doing it by hand takes hours. Let's automate it in about 70 lines of Python.






What we're building



A script that:




  1. Scans a folder of invoice PDFs

  2. Extracts GSTIN, invoice number, date, taxable value, CGST/SGST/IGST, and total

  3. Validates the GSTIN format (including the checksum-style structure)

  4. Writes everything to a clean CSV you can import into Tally or Excel






Setup






CODE
pip install pdfplumber






That's the only dependency. pdfplumber handles text extraction from digitally generated PDFs (which most GST invoices are).






The code






CODE
import csv
import re
import sys
from pathlib import Path

import pdfplumber

# GSTIN: 2-digit state code + 10-char PAN + entity code + 'Z' + check char
GSTIN_RE = re.compile(r"\b\d{2}[A-Z]{5}\d{4}[A-Z]\d[A-Z]\d\b")
INV_NO_RE = re.compile(r"(?:Invoice\s*(?:No|Number|#)\.?\s*[:\-]?\s*)([A-Z0-9\/\-]+)", re.I)
DATE_RE = re.compile(r"\b(\d{1,2}[\/\-]\d{1,2}[\/\-]\d{2,4})\b")
AMOUNT_RE = re.compile(r"(?:\u20b9|Rs\.?|INR)\s*([\d,]+\.?\d*)")

LABELS = {
"taxable": re.compile(r"taxable\s*(?:value|amount)\s*[:\-]?\s*(?:\u20b9|Rs\.?|INR)?\s*([\d,]+\.?\d*)", re.I),
"cgst": re.compile(r"CGST[^\d]*([\d,]+\.\d{2})", re.I),
"sgst": re.compile(r"SGST[^\d]*([\d,]+\.\d{2})", re.I),
"igst": re.compile(r"IGST[^\d]*([\d,]+\.\d{2})", re.I),
"total": re.compile(r"(?:grand\s*total|total\s*amount|amount\s*payable)\s*[:\-]?\s*(?:\u20b9|Rs\.?|INR)?\s*([\d,]+\.?\d*)", re.I),
}

STATE_CODES = {f"{i:02d}" for i in range(1, 39)}

def valid_gstin(gstin: str) -> bool:
return bool(GSTIN_RE.fullmatch(gstin)) and gstin[:2] in STATE_CODES

def to_float(s: str) -> float:
try:
return float(s.replace(",", ""))
except ValueError:
return 0.0

def parse_invoice(pdf_path: Path) -> dict:
with pdfplumber.open(pdf_path) as pdf:
text = "\n".join(page.extract_text() or "" for page in pdf.pages)

gstins = [g for g in GSTIN_RE.findall(text) if valid_gstin(g)]
inv_no = INV_NO_RE.search(text)
date = DATE_RE.search(text)

row = {
"file": pdf_path.name,
"vendor_gstin": gstins[0] if gstins else "NOT FOUND",
"invoice_no": inv_no.group(1) if inv_no else "NOT FOUND",
"date": date.group(1) if date else "NOT FOUND",
}
for field, pattern in LABELS.items():
m = pattern.search(text)
row[field] = to_float(m.group(1)) if m else 0.0

# Sanity check: taxable + taxes should roughly equal total
expected = row["taxable"] + row["cgst"] + row["sgst"] + row["igst"]
row["mismatch"] = "YES" if row["total"] and abs(expected - row["total"]) > 1 else ""
return row

def main(folder: str):
pdfs = sorted(Path(folder).glob("*.pdf"))
if not pdfs:
sys.exit(f"No PDFs found in {folder}")

rows = [parse_invoice(p) for p in pdfs]
out = Path(folder) / "invoices_extracted.csv"
with out.open("w", newline="") as f:
writer = csv.DictWriter(f, fieldnames=rows[0].keys())
writer.writeheader()
writer.writerows(rows)
print(f"Parsed {len(rows)} invoices -> {out}")
flagged = sum(1 for r in rows if r["mismatch"])
if flagged:
print(f"Warning: {flagged} invoice(s) have tax totals that don't add up — check manually.")

if __name__ == "__main__":
main(sys.argv[1] if len(sys.argv) > 1 else ".")









Running it






CODE
python gst_parser.py ~/Downloads/vendor-invoices/






Output:




CODE
Parsed 23 invoices -> invoices_extracted.csv
Warning: 2 invoice(s) have tax totals that don't add up — check manually.






That mismatch flag is my favourite part. It catches data-entry errors on the vendor's side and extraction failures on ours — anything where taxable value + CGST + SGST + IGST doesn't land within ₹1 of the stated total gets flagged for a human look.






Why regex and not AI?



For digitally generated invoices, regex is faster, free, and deterministic. A month of invoices parses in under two seconds with zero API costs. Where this approach breaks down is scanned/photographed invoices — for those, add an OCR step with pytesseract before the regex pass, or hand the text to an LLM for extraction.






Three upgrades worth making



Vendor name capture. Most invoices put the vendor name within a couple of lines of the GSTIN. Grab the surrounding lines and you can auto-fill the vendor column too.



GSTIN verification. The format check above catches typos, but the government's GST portal can confirm a GSTIN is actually registered. Useful before claiming input tax credit.



HSN code extraction. If you need item-level detail for GSTR filings, pdfplumber's extract_tables() handles the line-item tables most invoice formats use.






Wrap-up



Seventy lines, one dependency, and the monthly invoice grind becomes a two-second script run. The same pattern — extract text, regex the fields you care about, validate, write CSV — works for bank statements, salary slips, and purchase orders too.






Follow me on Twitter @automate_archit for daily AI automation tips.

Vollständiger Original-Bericht
Ausführliche Details, Code-Beispiele & Hersteller-Stellungnahme auf dev.to.
↗ Original-Artikel auf dev.to lesen
Wie bewertest du diesen Beitrag?
1 Klick Feedback
Teilen mit Netzwerk & Team:

Community-Analysen & Experten-Meinungen 0

Verfasse deine eigene Analyse, teile Workarounds oder diskutiere diesen Vorfall im Blog.
Noch keine Community-Analyse verfasst. Markiere einen Textabschnitt oder klicke oben auf Eigene Analyse verfassen“!
Community Pulse: Relevanz-Einschätzung
1 Klick Experten-Votum
🔴 Akute Relevanz 0%
🟡 In Evaluierung 0%
🟢 Keine Auswirkung 0%
Spannende Innovation 0%
Verwandte Story-Cluster & Quellen (Vektor-KI)
Port 8095 Engine
1 Quelle
How to Avoid Malware When Downloading TikTok Videos Online
1 Quelle
Microsoft Plans Windows 11 Age-Check Tool as Users Threaten Linux Switch
1 Quelle
Android VPN Lockdown Flaw Lets Apps Leak Users’ Real IP Addresses
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Build a GST Invoice Parser in 70 Lines of Python

Thematisch verwandte Begriffe: Build, Invoice, Parser, Lines · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...