Commit d8be8844 authored by justus.taeger's avatar justus.taeger
Browse files

python file

parent 97b1ce09
Patient_Id,City,Doctor
0,Boston,Dr. Bleimehl
1,Berlin,Dr. Täger
2,Tokyo,Dr. Täger
3,Elmshorn,Dr. Täger
4,Munich,Dr. Täger
5,Tokyo,Dr. Bleimehl
6,Boston,Dr. Bleimehl
7,London,Dr. Sommer
8,Elmshorn,Dr. Sommer
9,New York,Dr. Bleimehl
10,Shanghai,Dr. Jarasch
11,Berlin,Dr. Täger
12,Munich,Dr. Bleimehl
13,London,Dr. Bleimehl
14,Berlin,Dr. Sommer
15,Paris,Dr. Bleimehl
16,Elmshorn,Dr. Bleimehl
17,London,Dr. Täger
18,Boston,Dr. Sommer
19,Boston,Dr. Sommer
20,Boston,Dr. Täger
21,London,Dr. Jarasch
22,London,Dr. Täger
23,London,Dr. Bleimehl
24,Shanghai,Dr. Jarasch
Tubercolosis,Diabetes,Pneumonia,Cancer,Stroke,Diagnose_ID
0,0,0,0,0,0
0,0,0,0,1,1
0,0,0,1,0,2
0,0,0,1,1,3
0,0,1,0,0,4
0,0,1,0,1,5
0,0,1,1,0,6
0,0,1,1,1,7
0,1,0,0,0,8
0,1,0,0,1,9
0,1,0,1,0,10
0,1,0,1,1,11
0,1,1,0,0,12
0,1,1,0,1,13
0,1,1,1,0,14
0,1,1,1,1,15
1,0,0,0,0,16
1,0,0,0,1,17
1,0,0,1,0,18
1,0,0,1,1,19
1,0,1,0,0,20
1,0,1,0,1,21
1,0,1,1,0,22
1,0,1,1,1,23
1,1,0,0,0,24
1,1,0,0,1,25
1,1,0,1,0,26
1,1,0,1,1,27
1,1,1,0,0,28
1,1,1,0,1,29
1,1,1,1,0,30
1,1,1,1,1,31
import random
import csv
diseases = [
"Cancer",
"Diabetes",
"Heart Disease",
"Stroke",
"Alzheimer",
"Influenca",
"Syphilis",
"Pneumonia",
"Asthma",
"Tubercolosis",
]
diseases_selection = []
number_of_diseases = input("Anzahl an Krankheiten (bitte 1 bis 10 eingeben): ")
number_of_patients = input("Anzahl an Patienten: ")
number_of_patients = int(number_of_patients)
number_of_diseases = int(number_of_diseases)
for i in range(number_of_diseases):
tmp = random.choice(diseases)
diseases_selection.append(tmp)
diseases.remove(tmp)
disease_csv = []
disease_csv.append(diseases_selection)
import itertools
tmp_list = []
counter = -1
for i in range(len(diseases_selection)):
tmp_list.append([0, 1])
for element in itertools.product(*tmp_list):
counter += 1
element = list(element)
element.append(counter)
disease_csv.append(element)
diseases_selection.append("Diagnose_ID")
with open("disease.csv", "w", newline="") as file:
writer = csv.writer(file)
writer.writerows(disease_csv)
patients = []
patient_header = [
"Patient_Id",
"Age",
"Height",
"Weight",
"BMI",
"Gender",
"Diagnose_ID",
]
gender = ["f", "m", "div"]
diganose_IDs = []
for i in range(len(disease_csv) - 1):
diganose_IDs.append(i)
patients.append(patient_header)
for i in range(number_of_patients):
patient = []
patient.append(i)
patient.append(random.randint(10, 80))
height = random.randint(150, 200)
patient.append(height)
weight = random.randint(45, 120)
patient.append(weight)
patient.append(weight / (height / 100) ** 2)
patient.append(random.choice(gender))
patient.append(random.choice(diganose_IDs))
patients.append(patient)
with open("patient.csv", "w", newline="") as file:
writer = csv.writer(file)
writer.writerows(patients)
cities = [
"Munich",
"London",
"Tokyo",
"Shanghai",
"Berlin",
"New York",
"Boston",
"Paris",
"Elmshorn",
]
doctors = ["Dr. Sommer", "Dr. Bleimehl", "Dr. Jarasch", "Dr. Täger"]
city_doctor_csv = []
city_doctor_csv_header = ["Patient_Id", "City", "Doctor"]
city_doctor_csv.append(city_doctor_csv_header)
for i in range(len(patients) - 1):
city_doctor = []
city_doctor.append(i)
city_doctor.append(random.choice(cities))
city_doctor.append(random.choice(doctors))
city_doctor_csv.append(city_doctor)
with open("city_doctor.csv", "w", newline="") as file:
writer = csv.writer(file)
writer.writerows(city_doctor_csv)
Patient_Id,Age,Height,Weight,BMI,Gender,Diagnose_ID
0,73,187,114,32.60030312562555,m,7
1,13,183,46,13.735853563856788,div,27
2,55,151,95,41.6648392614359,f,11
3,46,172,118,39.88642509464576,f,8
4,66,157,59,23.93606231490121,div,19
5,58,184,84,24.8109640831758,div,4
6,44,156,81,33.28402366863905,div,31
7,45,173,54,18.042701059173375,div,25
8,68,151,86,37.71764396298408,div,7
9,53,170,59,20.41522491349481,div,28
10,61,185,80,23.37472607742878,f,9
11,57,188,94,26.595744680851066,f,25
12,50,191,71,19.462185795345523,m,24
13,17,189,103,28.834579099129364,div,17
14,80,166,98,35.56394251705618,div,31
15,40,182,45,13.58531578311798,m,29
16,64,150,45,20.0,f,28
17,78,189,54,15.117157974300833,div,8
18,55,182,104,31.397174254317108,div,21
19,39,195,114,29.98027613412229,m,13
20,78,153,99,42.29142637447136,m,30
21,41,181,109,33.271267665822165,div,15
22,40,188,56,15.844273426889997,m,7
23,35,185,106,30.97151205259313,f,4
24,79,190,107,29.639889196675902,div,16
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment