import pandas as pd
import [Link] as plt
print('++++++++++++++++++ Sree Ayyappa Public School +++++++++++++')
print(' Welcome to Students Module ')
print('-------------Select the correct choice to work on Student Module ------------- ')
option = 1
dfstudents=pd.read_csv('[Link]',
header=None,
names=['SchNo','Name','Class','Section'])
while (option != 6):
print()
print('1. Add a new student')
print('2. Update Student Record')
print('3. Delete Student Record')
print('4. View Students')
print('5. View Line Chart')
print('6. Exit Student Module')
option = int(input('Enter Choice : '))
#Code for addition
if (option == 1):
# Take details of the students
schoolNo = int(input('Enter School Number : '))
name = input('Enter Name : ')
stClass = input('Enter Class : ')
stSection = input('Enter Section : ')
# Code to add data to dataframe
# and write the updated dataframe to csv file
totalStudents = dfstudents['SchNo'].count()
[Link][totalStudents] = [schoolNo,name,stClass,stSection]
print(' OUTPUT ')
print('Student Added .......... ')
dfstudents.to_csv('[Link]',header=False,index=False)
print(dfstudents)
print(' ')
# Code for updation
elif (option == 2):
# Search Record with school number
schoolNo = int(input('Enter School Number : '))
indexno = [Link][dfstudents['SchNo'] == schoolNo].index
print([Link][dfstudents['SchNo'] == schoolNo])
print('What would you like to change?')
print('1. To Change School Number')
print('2. To Change Name')
print('3. To Change Class')
print('4. To Change Section')
print('5. Back to main menu')
changeoption = int(input('What would you like to change? : '))
# Code to change the Data as per input choice
if (changeoption == 1):
schoolNoNew = int(input('Enter New School Number : '))
[Link][indexno,'SchNo'] = schoolNoNew
dfstudents.to_csv('[Link]',header=False,index=False)
elif (changeoption == 2):
nameNew = input('Enter New Name : ')
[Link][indexno,'Name'] = nameNew
dfstudents.to_csv('[Link]',header=False,index=False)
elif (changeoption == 3):
classNew = input('Enter New Class : ')
[Link][indexno,'Class'] = classNew
dfstudents.to_csv('[Link]',header=False,index=False)
elif (changeoption == 4):
sectionNew = input('Enter New Section : ')
[Link][indexno,'Section'] = sectionNew
dfstudents.to_csv('[Link]',header=False,index=False)
print('Record Updated ......... ')
print([Link][dfstudents['SchNo'] == schoolNo])
print(' ')
#Code for deletion
elif (option ==3):
# Search Record with school number
schoolNo = int(input('Enter School Number : '))
indexno = [Link][dfstudents['SchNo'] == schoolNo].index
print(' OUTPUT ')
print([Link][dfstudents['SchNo'] == schoolNo])
deleteconfirm = input('Are You Sure You Want To Delete Record? (Y/N) : ')
# Code to change the Data as per input choice
if (deleteconfirm == 'Y' or deleteconfirm == 'y'):
dfstudents = [Link](indexno)
print('Record Deleted .........')
dfstudents.to_csv('[Link]',header=False,index=False)
print(' ')
#Code for vieweing records
elif (option ==4):
print('1. Display on the basis of school number')
print('2. Display on the basis of name')
print('3. Display on the basis of class')
print('4. Display on the basis of section')
print('5. Display all records')
print('6. Display top records')
print('7. Display bottom records')
print('8. Back to main menu')
displaychoice = int(input('Enter your choice : '))
print(' OUTPUT ')
if (displaychoice == 1):
schoolNoDisplay = int(input('Enter School Number : '))
print([Link][dfstudents['SchNo'] == schoolNoDisplay])
elif (displaychoice == 2):
nameDisplay = input('Enter Name to Search : ')
print([Link][dfstudents['Name'] == nameDisplay])
elif (displaychoice == 3):
classDisplay = input('Enter Class to Search : ')
print([Link][dfstudents['Class'] == classDisplay])
elif (displaychoice == 4):
sectionDisplay = input('Enter Section to Search : ')
print([Link][dfstudents['Section'] == sectionDisplay])
elif (displaychoice == 5):
print(dfstudents)
elif (displaychoice == 6):
toprecords = int(input('Enter The Top Number of Records to Display : '))
print([Link](toprecords))
elif (displaychoice == 7):
bottomrecords = int(input('Enter The Bottom Number of Records to
Display : '))
print([Link](bottomrecords))
print(' ')
#Code to display line chart
elif (option ==5):
print('1. Display class wise line chart')
print('2. Display section wise line chart')
print('3. Display Class and section wise line chart')
print('4. Back to main menu')
chartoption = int(input('Enter your choice : '))
#Display Class wise number of students
if (chartoption == 1):
dfTemp = [Link](['Class']).aggregate('count')
classes = [Link].to_list()
numberofstudents=dfTemp['SchNo'].to_list()
[Link](classes,numberofstudents)
[Link]('Classes')
[Link]('Number of Students')
[Link]('Class Wise Students')
[Link]()
#Display Section wise number of students
elif (chartoption == 2):
dfTemp = [Link](['Section']).aggregate('count')
sections = [Link].to_list()
numberofstudents=dfTemp['SchNo'].to_list()
[Link](sections,numberofstudents)
[Link]('Classes')
[Link]('Number of Students')
[Link]('Section Wise Students')
[Link]()
#Display Class & Section wise number of students
elif (chartoption == 3):
dfTemp = [Link](['Class','Section']).aggregate('count')
classsection = [Link].to_list()
classsectionlist=[]
for i in range(len(classsection)):
[Link](classsection[i][0] + '-' +
classsection[i][1])
numberofstudents=dfTemp['SchNo'].to_list()
[Link](classsectionlist,numberofstudents)
[Link]('Class-Section')
[Link]('Number of Students')
[Link]('Class - Section Wise Students')
[Link]()
print('------------Thanks for using Student Module ------------------ ')