Government exam results in India are often published as long PDFs with thousands of roll numbers. Searching them in a browser works, but when you are checking for a whole group of friends or students, a script is faster.
Install
pip install pdfplumber
Script
import pdfplumber, sys
pdf_path = sys.argv[1]
targets = set(sys.argv[2:])
with pdfplumber.open(pdf_path) as pdf:
for i, page in enumerate(pdf.pages, start=1):
text = page.extract_text() or ""
for t in targets:
if t in text:
print(f"{t} found on page {i}")
Run it with:
python find_roll.py result.pdf 2401001234 2401005678
Caveats
- Some PDFs are scanned images. You will need OCR (for example
pytesseract) for those. - Roll numbers can be split across lines in tables. Normalise whitespace if you get misses.
- Always confirm with the official PDF before celebrating.
Where do the PDFs come from? Official board sites, or a tracker that links to them. I use the Sarkari results page on govtpvt.com, which links the official result notice for each exam.
Top comments (0)