Skip to content
This repository was archived by the owner on Jun 4, 2025. It is now read-only.

Python tool for analyzing Bangladesh Railway seat matrices for segmented routes. Check seat availability, find optimized segmented paths, and display detailed fare breakdowns with VAT. Interactive terminal-based interface.

License

Notifications You must be signed in to change notification settings

nishatrhythm/Bangladesh-Railway-Segmented-Seat-Matrix-and-Details-Seat-Availabilty

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bangladesh Railway Segmented Seat Matrix and Details Seat Availabilty

This repository provides two powerful tools for visualizing and analyzing train seat availability in Bangladesh.

  1. Segmented Seat Matrix
    Visualize and analyze train seat matrices for different seat types on specific train routes in Bangladesh. It features scripts that fetch seat availability from a public API and construct segmented travel routes when direct routes are not available. This tool offers detailed seat information, including VAT.

  2. Detailed Seat Availability
    Fetches and categorizes seat layouts into Available or In Booking Process groups, organizes seat numbers by prefixes for clarity, and uses color-coded output for enhanced readability.

Segmented Seat Matrix

  • Real-Time Data Fetching: Retrieves seat availability for different train routes and seat types.
  • Seat Matrix Display: Presents seat matrices for each seat type in a tabular format.
  • Segmented Route Finder: Calculates and displays alternative travel paths if a direct route is unavailable.
  • Mixed Seat-Type Fallback: Automatically finds a mixed seat-type segmented route when no full same-type route is available.
  • Detailed Fare Breakdown: Shows base fare, VAT, service charges, and bedding charges (for specific seat types) for direct and segmented routes.
  • Interactive User Interface: Menu-driven prompts for ease of use.

Sample Run

Below is an example of the script running in the terminal:

Script running in terminal

Installation

  1. Clone the repository:
    git clone https://github.com/nishatrhythm/Bangladesh-Railway-Segmented-Seat-Matrix-and-Details-Seat-Availabilty.git
    cd Bangladesh-Railway-Segmented-Seat-Matrix-and-Details-Seat-Availabilty
  2. Install required Python packages: Ensure you have the required Python packages installed:
    pip install requests tabulate colorama

Usage

  1. Modify the script:

    • You need to update the target_train_model and date_of_journey variables in the seatMatrixWithSegmentation.py script to match your desired train model and date.
    target_train_model = "781"  # This can be set to match the desired train model
    date_of_journey = "15-Nov-2024"  # This can be modified as needed
  2. Run the script:

    python seatMatrixWithSegmentation.py
  3. Menu Options:

    • Select 1 to check seat availability and enter origin and destination stations.
    • Select 2 to exit the program.
  4. Output Details:

    • Displays seat matrices for each seat type if seats are available.
    • Shows direct routes with a breakdown of base fare and VAT.
    • Finds and displays segmented routes if a direct route is not available.
    • Displays mixed seat-type segmented routes as fallback when same-type routes are not available.
    • Clearly highlights segment dates when journey spans multiple days.

Example Output for a Route

Enter the origin station: Dhaka
Enter the destination station: Cox's Bazar

Finding segmented route for seat type: AC_B

Direct route available for seat type AC_B from Dhaka to Cox's Bazar.
Base Fare: 2069 | VAT: 311 | Charge: 20 | Bedding: 50

Total Fare: 2450

Finding segmented route for seat type: SNIGDHA
Segmented route found for seat type SNIGDHA:
- Dhaka to Chattogram (starts from Dhaka on 18-May-2025)
Base Fare: 743 | VAT: 112 | Charge: 20 | Total: 875

- Chattogram to Cox's Bazar (starts from Chattogram on 19-May-2025)
Base Fare: 408 | VAT: 62 | Charge: 20 | Total: 490

Total Fare: 1365

Detailed Seat Availability

Features

  • Detailed Seat Layout: Fetches and displays the seat layout, categorizing seats as available or in the booking process.
  • Grouped Seat Information: Groups seat numbers by their prefixes for better clarity.
  • Color-Coded Output: Utilizes colorama to color-code the output for enhanced readability.

Sample Run

Below is an example of the script running in the terminal:

Script running in terminal

Installation

Ensure you have the following Python packages installed:

pip install requests tabulate colorama

Usage

  1. Configure the Script:

    Update the following variables in the detailsSeatAvailability.py script:

    TOKEN = 'your_token_here'                # Replace with your authorization token
    
    CONFIG = {
        'from_city': 'Dhaka',                # Set the origin city
        'to_city': 'Joydebpur',              # Set the destination city
        'date_of_journey': '03-Dec-2024',    # Set the date of journey
        'seat_class': 'S_CHAIR'              # No need to change this
    }
  2. Run the Script:

    python detailsSeatAvailability.py
  3. Output Details:

    • Train Details: Displays train name, departure, and arrival times for the selected route.
    • Seat Availability: Categorized by seat type, with seats grouped by prefixes for better organization.
    • Color-Coded Table: Indicates available seats and those in the booking process with visual distinctions for easy comprehension.

Example Output

TISTA EXPRESS (707) (03 Dec, 07:30 am - 03 Dec, 08:19 am) (Dhaka - Joydebpur)
================================================================================
 
Seat Type: SNIGDHA
Available Tickets: 0 ticket | In Booking Process: 2 tickets
+-------------------------------------+----------------+
| Status                              | Seat Numbers   |
+=====================================+================+
| In Booking Process (JA) - 2 tickets | JA-4, JA-19    |
+-------------------------------------+----------------+
 
Seat Type: S_CHAIR
Available Tickets: 19 tickets | In Booking Process: 2 tickets
+--------------------------------------+-------------------------------------------------+
| Status                               | Seat Numbers                                    |
+======================================+=================================================+
| Available (THA) - 19 tickets         | THA-4, THA-6, THA-10, THA-12, THA-14, THA-17,   |
|                                      | THA-18, THA-20, THA-23, THA-31, THA-32, THA-30, |
|                                      | THA-29, THA-34, THA-36, THA-35, THA-39, THA-40, |
|                                      | THA-38                                          |
+--------------------------------------+-------------------------------------------------+
| In Booking Process (NEO) - 2 tickets | NEO-55, NEO-56                                  |
+--------------------------------------+-------------------------------------------------+
No seat details available for seat type: AC_S

About

Python tool for analyzing Bangladesh Railway seat matrices for segmented routes. Check seat availability, find optimized segmented paths, and display detailed fare breakdowns with VAT. Interactive terminal-based interface.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages