Click here to Skip to main content
15,887,936 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Read employee list from file This feature allows the application to read the data from the data file and store in a list the employee id and name of the employees. The system should prompt the user for the name of the data file. The number of records read is displayed as shown in Figure 3:

Option 1: Read employee list from file
Enter the name of the data file: Assignment_Data1.csv
Number of records read: 5


I have already created a main menu , so after i type 1 , the user has to type the name of the file which is Assignment_Data1.csv. Then, the number of records will be shown.

What I have tried:

def main_menu():

     print('''\nMAIN MENU
=======
[1] Read Employee List From File
[2] Display Employee ID and Name of all Employees
[3] Search For Employee
[4] Take Attendance
[5] View Attendance
[6] Export Attendance to File
[7] Poll Attendance
[0] Exit ''')

def employee_list():
     print('\nOption 1:Read Employee List from file\n')
     #name=input("Enter the name of the data file:")
     filename=input("Enter the name of the data file:")
     name= 'Assignment_Data1.csv'
     file=open(name)
     file.readline()
     for line in file:
          line=line.strip('\n')
          employee_list.append(line.split(','))
     print('Number of Records Read:',len(employee_list))


while True:
     main_menu()
     option=int(input('Enter  Your Option:'))
     if (option==1):
          employee_list()
     elif (option==2):
          display_employee()
     elif (option==3):
          search_employee()
     elif (option==4):
          take_attendance()
     elif (option==5):
          view_attendance()
     elif (option==6):
          export_attendance()
     elif (option==7):
          poll_attendees()
     elif (option==0):
          print('Wrong Input!')
     else:
          print(33* '   ')
          print('Invalid Option, Please try again.')
          print(33*'   ')
Posted
Comments
[no name] 23-Jul-18 2:48am    
And your "question" is?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900