Advertisement
Guest

Task7

Sep 20th, 2026
8
0
Never
Not a member of GistPad yet? Sign Up, it unlocks many cool features!
  1. import csv
  2. import sys
  3. from tabulate import tabulate
  4.  
  5. path = '/home/engerroz/projects/006_Team_ITS_ID_1517518-Team_TL-Wallykou_56f97d62_4301_4602-1/src/materials/schedule.csv'
  6.  
  7. # Читаем файл
  8. with open(path, 'r', encoding='utf-8', newline='') as f:
  9. reader = csv.reader(f)
  10. rows = list(reader)
  11.  
  12. user_input = input('Enter the full name of the patient separated by space (Ivanov Ivan Ivanovich): ')
  13. patient_name = user_input.strip().title()
  14. patient_found = False
  15.  
  16. for row in rows:
  17. if row[1] == patient_name:
  18. row[2] = "Yes"
  19. patient_found = True
  20.  
  21. if not patient_found:
  22. print('There is no such patient!')
  23. sys.exit()
  24.  
  25. # Перезаписываем файл с обновлёнными данными
  26. with open(path, 'w', encoding='utf-8', newline='') as f:
  27. writer = csv.writer(f)
  28. writer.writerows(rows)
  29.  
  30. print(tabulate(rows, headers='firstrow', tablefmt='github'))
RAW Paste Data Copied
Advertisement
Advertisement