-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparserPatients.py
38 lines (28 loc) · 1.07 KB
/
parserPatients.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from datetime import datetime
from classes import Patient
from variablesFiles import *
def parsePatients():
dicPatients = {}
nameFile = setFileInput(filesName["patient"])
with open(nameFile) as file:
for lineString in file:
lineString = str(lineString)
if lineString[0].isnumeric():
line = lineString.split(',')
id = int(line[0])
birth_str = line[2]
birth = datetime.strptime(birth_str, '%Y-%m-%d %H:%M:%S')
sexLetter = line[1]
if (sexLetter == 'M'):
sex = False
else:
sex = True
death = line[len(line)-1].rstrip()
if death=='1':
death = True
elif death=='0':
death = False
patient = Patient(id,birth,sex,death)
dicPatients[id] = patient
file.close()
return dicPatients