Compare commits

..

2 Commits
main ... master

Author SHA1 Message Date
MoritzLutz cd615c1938 test push 2023-01-10 12:51:39 +01:00
MoritzLutz ea7143df3f s2_a3 2023-01-10 12:48:52 +01:00
2 changed files with 63 additions and 15 deletions

View File

@ -1,15 +0,0 @@
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
plt.title('ChatGpt seine Lernkurve')
a = np.random.random((100,100))
plt.imshow(a)
plt.hot()
plt.colorbar()
plt.show()

63
s2_a3.py 100644
View File

@ -0,0 +1,63 @@
import re
import json
#this is a test comment
person_list = []
with open("Studienleistung2/Personen.txt") as input:
for lines in input:
current_line = lines.split(",")
titel = re.findall(r"([A-Z][a-z]+\.)", current_line[0])
name = re.findall(r"([A-Z][a-z]+[^\.]*$)", current_line[0])
name = re.split("\s", name[0])
# getting the fragments building the whole name
first_name = name[0]
# if there are more than one second names
second_name = ""
counter = 1
while counter<len(name)-1:
second_name = second_name + name[counter] + " "
counter += 1
# -1 to get the last elem of the list name
last_name = name[-1]
address = re.findall(r"(.+)([1-9]+).([\d]{5})(.+)", current_line[1])
address = address[0]
street_name = address[0]
house_number = address[1]
plz = address[2]
city = address[3]
geb_date = re.findall("([0-9][0-9]\.[0-9][0-9]\.[0-9][0-9][0-9][0-9])", current_line[2])
tel = re.findall("(\d{12,15})", current_line[3])
person = {
"titel": titel[0],
"Vorname": first_name,
"Zweitname": second_name,
"Nachname": last_name,
"Straße": street_name,
"Hausnummer": house_number,
"PLZ": plz,
"Stadt": city,
"Geb.Datum": geb_date[0],
"Tel.": tel[0],
}
person_list.append(person)
with open("Studienleistung2/Person_Neu.json", "w") as outfile:
json.dump(person_list, outfile, indent=2, ensure_ascii=False)