parent
b5eb02db6b
commit
588529032e
36
SL2/s2_a3.py
36
SL2/s2_a3.py
|
@ -1,7 +1,8 @@
|
|||
import re
|
||||
import json
|
||||
import string
|
||||
|
||||
text_file = open(r"Name.txt", "r")
|
||||
text_file = open(r"Personen.txt", "r")
|
||||
data = text_file.readlines()
|
||||
arr = [None] * len(data)
|
||||
counter = 1
|
||||
|
@ -10,12 +11,13 @@ text_file.close()
|
|||
for line in data:
|
||||
|
||||
data_array = re.split(",", line)
|
||||
|
||||
name = data_array[0]
|
||||
name_array = re.split("\s",name)
|
||||
adresse = data_array[1]
|
||||
geburtsdatum = data_array[2]
|
||||
telefon = data_array[3]
|
||||
adresse1 = data_array[1]
|
||||
adresse2 = data_array[2]
|
||||
geburtsdatum = data_array[3]
|
||||
telefon = data_array[4]
|
||||
telefon = telefon.replace("\n", "")
|
||||
|
||||
titel = re.search("^.*\.$",name_array[0])
|
||||
|
||||
|
@ -40,15 +42,19 @@ for line in data:
|
|||
nachname = name_array[1]
|
||||
zweitname = None
|
||||
|
||||
adresse_array = re.split("\s", adresse)
|
||||
plz = re.findall("\d{5}", adresse)
|
||||
hausnummer = re.findall(r"\b\d{1,4}\b", adresse)
|
||||
chars = re.split("\d",adresse)
|
||||
strasse = chars[0]
|
||||
ort = adresse_array[len(adresse_array)-1]
|
||||
# adresse_array = re.split("\s", adresse)
|
||||
plz = re.findall("\d{5}", adresse2)
|
||||
hausnummer = re.findall(r"\b\d{1,4}\b", adresse1)
|
||||
strasse_chars = re.findall("\D",adresse1)
|
||||
strasse = ''.join(strasse_chars)
|
||||
strasse = strasse.replace("\"", "")
|
||||
ort_chars = re.findall("\D",adresse2)
|
||||
ort = ''.join(ort_chars)
|
||||
ort = ort.replace("\"", "")
|
||||
|
||||
geburtsdatum = re.findall("[0-9][0-9]\.[0-9][0-9]\.[0-9][0-9][0-9][0-9]", line)
|
||||
telefon = re.findall("\d{6,20}", line)
|
||||
|
||||
geburtsdatum = re.findall("[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]", line)
|
||||
# telefon = re.findall("\d{6,20}", line)
|
||||
|
||||
person = {
|
||||
"Index" : counter,
|
||||
|
@ -66,9 +72,9 @@ for line in data:
|
|||
|
||||
arr[counter - 1] = person
|
||||
counter = counter + 1
|
||||
print(counter)
|
||||
|
||||
|
||||
with open(r"PersonNeu.json", "w") as f:
|
||||
with open(r"PersonenNeu.json", "w") as f:
|
||||
json.dump(arr,f, indent=1, ensure_ascii=False)
|
||||
|
||||
f.close()
|
Loading…
Reference in New Issue