0% found this document useful (0 votes)
11 views28 pages

Ip Project

The document outlines a Railway Reservation System project developed using Python and CSV for ticket booking and cancellation. It includes sections on project objectives, systematic implementation, source code, outputs, and installation instructions for Python. Acknowledgments are given to contributors, and the document concludes with a certificate of completion for the project.

Uploaded by

jdtube47
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views28 pages

Ip Project

The document outlines a Railway Reservation System project developed using Python and CSV for ticket booking and cancellation. It includes sections on project objectives, systematic implementation, source code, outputs, and installation instructions for Python. Acknowledgments are given to contributors, and the document concludes with a certificate of completion for the project.

Uploaded by

jdtube47
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 28

CONTENTS

1.Introduction ……………………………………….…

2.Objective of the project ………….………………..

3.CSV…………………………………………………....

4. Systematic Implementation ………………………

4.1 The software used

4.2 The hardware used

5.Source Code ……………………………….………..

6.Outputs ………………………………………….……

7.How to install Python………………………………

8. Bibliography…………………………………………
ACKNOWLEDGEMENT

Apart from the efforts of us, the success of any


project depends largely on the encouragement and
guidelines of many others. We take this opportunity
to express our gratitude to the people who have
been instrumental in the successful completion of
this project.
We express our heartfelt gratitude to our parents for
constant encouragement while carrying out this
project.
We express our deep sense of gratitude to Dr.

Peeyush Moonat The Principal, who has been


continuously motivating and extending their helping
hand to us.
We are overwhelmed to express our thanks to The
Administrative Officer for providing us with
infrastructure and moral support while carrying out
this project in the school.
Our sincere thanks to Mr. Kapil Upadhyay, A guide,
Mentor, all the above a friend, who critically
reviewed our project and helped in solving each and
every problem, occurred during implementation of
the project.
Signature of Principal Signature of External
RAILWAY RESERVATION SYSTEM

INTRODUCTION

The railway reservation system is basically a CSV based


project done with help of python language. This project is very
useful for people to book or cancel train tickets. This project
can be modified for various reservations.

OBJECTIVES OF THE PROJECT

The objective of this project is to apply the programming


knowledge into a real- world situation/problem and expose the
how programming skills helps in developing a good software.

• Write programs utilizing modern software tools.


• Apply object oriented programming principles effectively
when developing small to medium sized projects.
• Write effective procedural code to solve small to medium
sized problems.
• We will demonstrate a breadth of knowledge in computer
science, as exemplified in the areas of systems, theory
and software development.
• We will demonstrate ability to conduct a research or
applied Computer Science project, requiring writing and
presentation skills which exemplify scholarly style in
computer science.
Multiple levels of testing are performed, including :

• Testing at the development facility by the


contractor and possibly supported by end users

• Testing as a deployed system with end users working


together with contract
personnel

• Operational testing by the end user alone performing


all functions. Requirements are traced throughout
testing,a final Independent Verification & Validation
evaluation is performed and all documentation is
reviewed and accepted prior to

FLOW CHART

4. THEN THE DATA WILL 1. COMMANDED


BE SEND TO THE PROGRAM WILL BE
PYTHON . EXECUTED IN PYTHON

3. THE REQUIRED 2. AS THE PYTHON AND


DATA WILL BE CSV ARE CONNECTED
THE COMMAND WILL BE
TAKEN FROM THE
SENT TO CSV.
CSV.
SOURCE CODE

# Railway Reservation System

import pandas as pd
import os

import datetime
date =
str(datetime.datetime.now())
date = date[:19]

file =

open('receipt.txt','w')

import warnings
warnings.filterwarnings('ignore') #to ignore warning raised by
altering
the dataframe

all_trains = pd.read_csv(r'trains.csv') #importing all trains data


from excel sheet in a dataframe
a0001 = pd.read_csv(r"A0001.csv") #importing 1st data from
excel sheet in a dataframe
a0002 = pd.read_csv(r"A0002.csv") #importing 2nd data from
excel sheet in a dataframe
a0003 = pd.read_csv(r"A0003.csv") #importing 3rd data from
excel sheet in a dataframe
a0004 = pd.read_csv(r"A0004.csv") #importing 4th data from
excel sheet in a dataframe
a0005 = pd.read_csv(r"A0005.csv") #importing 5th data from
excel sheet in a dataframe

coach_list = ['1st AC','2nd AC','3rd AC','2S','SL'] #creating a list of all


the coaches

passengers = pd.read_csv(r"passengers.csv") # importing all


passengers data in a dataframe
cancelled = pd.read_csv(r'cancelled.csv') # importing all
cancelled passengers data in a dataframe

print() # styling

def PNR(): # function to assign PNR number


last_assigned_pnr = passengers.iloc[-1,0] # calling last assigned pnr
from passengers data
global new_pnr
new_pnr = last_assigned_pnr + 1

def booking():
PNR() #calling the function
print("="*65) #styling
print("\t\t\tWelcome to Booking Department")
print("="*65) #styling
print("-"*65) #styling
print("\t\t\tSelect from following
trains") print("-"*65,'\n') #styling
print(all_trains)

while True: #taking out dataframe based on train


number train_no = str(input("Enter train number from
above list : ")) print() #styling
if train_no == 'a0001' or train_no == 'A0001':
train_no = a0001
break
elif train_no == 'a0002' or train_no ==
'A0002': train_no = a0002
break
elif train_no == 'a0003' or train_no ==
'A0003': train_no = a0003
break
elif train_no == 'a0004' or train_no ==
'A0004': train_no = a0004
break
elif train_no == 'a0005' or train_no ==
'A0005': train_no = a0005
brea
k else:
print("Please enter correct train number!! \n")

print("-"*65) #styling
print('\t\t\tCurrent seat
status') print('-'*65,'\n')
#styling

print(train_no)

while True:
coach = input("Enter exact coach as written in table for
which you want seat(s) : ") #taking desired coach type from
user
if coach in coach_list: #if it matches with the coach present in
the coach_list

number_of_seats = int(input("Enter number of seat(s)


you want : ")) #inputting number of desired seats

index = train_no[train_no['Coach']==coach].index.values
#taking out the index at which coach type is present
train_no.Seats[index] -= number_of_seats #differencing
the inoutted number of seats on that index(coach)

Price = int(train_no.Fare[index]) #storing price of one


ticket in a varibale
train_no.to_csv(train_no.iloc[0,0]+'.csv',index=False)
#sending all the data to excel sheet with indexing off to avoid
undesireable results

file.write('\n\n\n') #styling
file.write("="*73);file.write('\n') #styling
file.write("\t\t\tINVOICE\t\t");file.write('\n')
file.write("="*73);file.write('\n') #styling

file.write("DATE:\t\t\t\t");
file.write(str(date));file.write('\n')

file.write("="*73);file.write('\n')
#styling file.write("Train No.\
tCoach\tNo. of
Seats\tPrice\t\tTotal");file.write('\n') #styling

file.write(str(train_no.iloc[0,0]));
file.write('\t\t');
file.write(coach); file.write('\
t\t\t');
file.write(str(number_of_seat
s)); file.write('\t\t\t');
file.write(str(Price));
file.write('\t\t\t');
file.write(str(Price*number_of_seats));file.writ

e('\n') file.write("-"*73);file.write('\n') #styling


file.write("GRAND TOTAL: \t\t");
file.write(str(Price*number_of_seats));file.write('\n')

file.write("="*73);
file.write('\n')#styling

file.write("Your PNR is :
");
file.write(str(new_pnr));
file.write('\n') #styling

current_seat_status = int(train_no.Seats[index]) #storing


the current seat status in a variable
final_seat_number = ''

for i in range(number_of_seats): #for assigning the seat


numbers seat_number = 100-current_seat_status #taking
out a single
seat number
current_seat_status += 1 #incrementation by 1
because that seat number is assigned
cancelled_indexes =
list(cancelled[cancelled['Coach']==coach].index.values) and
list(cancelled[cancelled['Train
No.']==train_no.iloc[0,0]].index.values)
for j in cancelled_indexes: #checking in the cancelled list if
seat number is available
seat_number = cancelled['Seat No.'][j] #if found for
the coach type and train that cancelled seat number will be
assigned
cancelled.drop(j,inplace = True) #dropping that
cancelled seat number from cancelled list
break
final_seat_number = final_seat_number +
str(seat_number) + ' ' #making a string of all assigned seat
numbers
passengers.loc[len(passengers.index)] =
[new_pnr,name,train_no.iloc[0,0],coach,seat_number]
#updating the current passengers dataframe with newly
assigned seat numbers
passengers.to_csv(r"passengers.csv",index=False)
#updating the passengers excel file with newly assigned seat
numbers
cancelled.to_csv(r'cancelled.csv',index = False) #also
updation of cancelled list

file.write("Your seat number(s) is/are : ")


file.write(final_seat_numb
er) file.write('\n')
brea
k else:
print('Ensure that you written the same coach as written
in the above table')

def PNR_Enquiry():
pnr = int(input("Enter your PNR :
")) print()
index = passengers[passengers['PNR
No.']==pnr].index.values #finding the index of passengers
given pnr number
index = index[::-
1] for i in index:
print(passengers.loc[i],'\n\n') #printing the seat number of
the selected index(PNR number)

def Cancel_Ticket():
pnr = int(input("Enter your PNR :
")) global value #creating a global
variable
passengers = pd.read_csv(r"passengers.csv") # importing
the passengers list in dataframe
value = passengers[passengers['PNR
No.']==pnr].index.values #finding the index of passengers
given pnr number
for i in value:
cancelled.loc[len(cancelled.index)] = passengers.iloc[i]
#dropping the passengers data from dataframe
passengers.drop(value,inplace=True) #updating the
dataframe print()
print()
print("Your ticket(s) have been susscessfully
Cancelled !!!") print()
print()
cancelled.to_csv(r'cancelled.csv',index=False) #updating the
cancelled excel file
passengers.to_csv(r'passengers.csv',index=False) #updating
the passengers excel file

name = input("Please Enter your name : ") # taking name from the
user
while True : #Making all the things in a loop, exit only when
4(Exit) is given as input

print("""\n\nPlease Enter your choice in numbers \n1. Booking


Ticket
\n2. PNR Enquiry \n3. Cancellation \n4. Exit""")
work_type = input('Enter : ') #Taking the input which work
user wants to do

try:
work_type = int(work_type)
except:
ValueError

if work_type == 1:
booking()
file =
open('receipt.txt','r')
data = file.read()
file.close()
print(data)

print_input = input("Do you want to print the bill


[Y/N] : ") if print_input=='y' or print_input=='Y':
os.startfile(r'C:\Users\jayda\Desktop\mazedaar scripts\Railway
Reservation System\receipt.txt','print')
else:
print("Thank you for saving the
environment!!") elif work_type == 2:
PNR_Enquiry()
elif work_type
== 3:
Cancel_Ticket()
elif work_type
== 4:
file.close()
print("\n\nThank You For Using a Software Made By JD!!!\n\n")
#Signature Closure message
brea
k else:
print("\nWrong Choice or Please enter value in a number\n")
OUTPUT

If you choose 1
If you choose 2

If you choose 3
If you choose 4
4.1 SOFTWARE REQUIREMENTS:

• Windows OS
• Python Spyder 2.7 or higher should be installed
• CSV with Connect database
• Python -CSV connector module should be installed

4.2HARDWARE REQUIREMENTS :

 Intel atom or similar processor based PC at


Client/Server end.

 512 MB RAM and 4GB HDD space (for database) is


desirable.

 Standard I/O devices like keyboard and mouse etc.

 Printer Is needed for hard-copy reports.

 LAN is required for client – server installation.


BIBLIOGRAPHY

In order to work on this project titled –


Railway Reservation System , the following
are referred for the project :

1. https://www.CSV.org/
2. https://www.python.org/
3. Informatics Practices(new) XII- Sumita
Arora
4. https://www.slideshare.com

Other than above mentioned , the suggestions


& supervisions of our teacher and my class
experience also helped me to develop this
software project.
Jaora Public School is a prominent school,
affiliated to Central
Board of Secondary Education (CBSE). The School
imparts academic excellence along with value based
quality education to become successful
entrepreneurs and leaders. The School takes care of
the holistic development of the child by providing
ample opportunities. The School also organizes
Inter-House Competition to the wes. The School
caters to the needs of more than 1200 wes, in its
sprawling campus which has huge acres of land.
The School has well equipped state-of art laboratories
and highly qualified faculty members.

The School is fully equipped with well-ventilated


Classrooms, Staff rooms, Library having the excellent
collection on Books, Art room, Physical Education Room,
Sports Rooms, Audio visual room, Dance Room, Medical
Room

Jaora Public School was founded in 2002, with a


mission to provide the Jaora's youth with an opportunity
to acquire an allround education. Today, it is one of the
landmark schools in Ratlam district, owing to the
relentless efforts of its founder and his competent team.
JPS endorses a holistic education model where each
child has her or his own unique identity and self-
esteem, which is valued and promoted. The high quality
educational environment has the greatest positive effect
on the life of a we.

School attempt to create an atmosphere of space,


freedom, care and security in which they are nurtured to
expand their horizons and grow.
The intention of the school is to awaken the intelligence
and the generosity of spirit in wes so that they are able
to meet an increasingly complex world without losing
their identity.

The cultivation of a global outlook, a love for nature


and a concern for humanity are all part of our
educational aims.
HOW TO INSTALL PYTHON :

1. Go to python.org

2. Download the latest release

3. Select the appropriate version for

your system
4. Follow the on-screen instruction
CERTIFICATE

This it to certify that the project entitled


Railway Reservation System is a bonafide
work done by Miss. Jenny Pagariya and
Miss. Vidhi Dangi class XII Session 2024-
2025 in partial fulfillment of CBSE’s
AISSCE Examination 2024 and has been
carried out under my direct supervision and
guidance. This report or a similar report on
the topic has not been submitted for any
other examination and does not form a part
of any other course undergo by the
candidate.

………………….. …………………..
Signature of Teacher Signature of
External
…………………..
Signature of Principal
CSV

Comma-separated values (CSV) is a text


file format that uses commas to separate values,
and newlines to separate records. A CSV file
stores tabular data (numbers and text) in plain
text, where each line of the file typically represents
one data record. Each record consists of the same
number of fields, and these are separated by
commas in the CSV file. If the field delimiter itself
may appear within a field, fields can be
surrounded with quotation marks.

The CSV file format is one type of delimiter-


separated file format. Delimiters frequently used
include the comma, tab, space, and semicolon.
Delimiter-separated files are often given a
".csv" extension even when the field separator is
not a comma. Many applications or libraries that
consume or produce CSV files have options to
specify an alternative delimiter.

The lack of adherence to the CSV standard RFC


4180 necessitates the support for a variety of CSV
formats in data input software. Despite this
drawback, CSV remains widespread in data
applications and is widely supported by a variety of
software, including common spreadsheet
applications such as Microsoft Excel. Benefits
cited in favor of CSV include human readability
and the simplicity of the format.
A project report on
RAILWAY RESERVATION SYSTEM

for
AISSCE 2O25 EXAMINATION

By :

Vidhi Dangi
&
Jenny Pagariya
Under the Guidance of :
Mr. Kapil Upadhyay

You might also like