Not a member of GistPad yet?
Sign Up,
it unlocks many cool features!
- import csv
- import sys
- from tabulate import tabulate
- path = '/home/engerroz/projects/006_Team_ITS_ID_1517518-Team_TL-Wallykou_56f97d62_4301_4602-1/src/materials/schedule.csv'
- # Читаем файл
- with open(path, 'r', encoding='utf-8', newline='') as f:
- reader = csv.reader(f)
- rows = list(reader)
- user_input = input('Enter the full name of the patient separated by space (Ivanov Ivan Ivanovich): ')
- patient_name = user_input.strip().title()
- patient_found = False
- for row in rows:
- if row[1] == patient_name:
- row[2] = "Yes"
- patient_found = True
- if not patient_found:
- print('There is no such patient!')
- sys.exit()
- # Перезаписываем файл с обновлёнными данными
- with open(path, 'w', encoding='utf-8', newline='') as f:
- writer = csv.writer(f)
- writer.writerows(rows)
- print(tabulate(rows, headers='firstrow', tablefmt='github'))
RAW Paste Data
Copied
Advertisement
