A Python command-line tool for searching keywords across Pakistani government documents.
The tool searches multiple .txt documents, returns matching lines with surrounding context, and records searches in a CSV history file.
- Keyword Search — search across multiple government text documents.
- Context Display — shows one line before and after each matching result.
- Search History — records searches with date and time in
history.csv. - Error Handling — handles invalid queries and missing document folders.
- Modular Structure — separates document reading, search logic, and custom exceptions.
- Command-Line Interface — designed to run directly from a terminal.
- Python 3
oscsvredatetimesys
- File I/O
- Text processing
- Regular expressions
- Command-line arguments
- CSV data handling
- Exception handling
- Modular Python design
Pakgov-search-cli/
│
├── docs/ # Text documents searched by the tool
├── search.py # Main search functionality
├── document_reader.py # Document reading logic
├── exceptions.py # Custom exceptions
├── history.csv # Search history
├── .gitignore
├── LICENSE
└── README.md
- Place searchable
.txtdocuments inside thedocs/directory. - Run the CLI from the project directory.
- Enter a keyword to search.
- The program scans the available documents.
- Matching results are displayed with surrounding context.
- The search is recorded in
history.csv.
Clone the repository:
git clone https://github.com/salikhussain71-code/Pakgov-search-cli.gitEnter the project directory:
cd Pakgov-search-cliRun the main program:
python search.pyMake sure the docs/ directory contains the .txt documents you want to search.
Finding specific information across large collections of government documents can be time-consuming when performed manually.
This project provides a lightweight command-line approach for searching local document collections and displaying relevant context around matches.
This project is licensed under the MIT License.