Advertisement
Guest User

Untitled

a guest
Oct 14th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.95 KB | None | 0 0
  1. #displays average time of all students
  2. def display_times():
  3. print('hello')
  4. all_average_pupils_times=[]
  5. print(all_average_pupils_times)
  6. with open('pupil_times.txt', 'rU') as csvfile:
  7. reader = csv.reader(csvfile)
  8. for row in reader:
  9. if (row):
  10.  
  11. all_average_pupils_times.append(row)
  12. print(all_average_pupils_times)
  13.  
  14.  
  15.  
  16. csvfile.close()
  17. records =all_averagetime_Tv.get_children()
  18. for elements in records:
  19. all_averagetime_Tv.delete(elements)
  20.  
  21. for row in all_average_pupils_times :
  22. all_averagetime_Tv.insert('','end',text=row[0],values=(row[1],row[2]))
  23.  
  24. #we are now going to write to a word document
  25. word = open('All pupil average time .doc','w')
  26. #we are now going to right each line
  27. word.write('\t' +'\t' +'\t' +'Average ski time of all students'+'\n'+'\n'+'\n')
  28. #now we are going to create a for loop and use the variable i to take on the data in each part of the array as the for loop progesses
  29. for i in all_average_pupils_times:
  30. #we now write the pupil id and use spaces to space out properly
  31. word.write('Pupil Id - '+i[0]+'\n')
  32. #we now write the pupil firstname and use spaces to space out properly
  33. word.write('Firstname - '+i[1] +'\n')
  34. #we now write the pupil surname and use spaces to space out properly
  35. word.write('Surname - '+i[2] +'\n')
  36. #we now write the pupil Average time and use spaces to space out properly
  37. word.write('Average time - '+i[2] + ' Seconds'+'\n' )
  38. #Get the current date
  39. current_date = datetime.datetime.now()
  40.  
  41. print(current_date)
  42. word.write('Date: '+str(current_date.day) +'/' + str(current_date.month)+'/' + str(current_date.year) +'\n')
  43. word.write('Time: '+str(current_date.hour)+':'+str(current_date.minute)+str(current_date.second) +'\n' +'\n')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement