Dateien hochladen nach „SL2“
parent
35ef3da324
commit
0e3a09ba8d
|
@ -0,0 +1,13 @@
|
|||
class Tier:
|
||||
def __init__(self,beine) -> None:
|
||||
self.beine = beine
|
||||
|
||||
class Hund(Tier):
|
||||
def __init__(self, name):
|
||||
super().__init__(4)
|
||||
self.name = name
|
||||
|
||||
class Rottweiler(Tier, Hund):
|
||||
def __init__(self):
|
||||
super().__init__(4, "Harald")
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
import re
|
||||
txt = "If the the problem is textual, use the the re module"
|
||||
txt = re.sub("the the", "the", txt)
|
||||
print(txt)
|
|
@ -0,0 +1,72 @@
|
|||
import re
|
||||
import json
|
||||
|
||||
text_file = open(r"C:\Users\denni\Documents\Bundeswehr\HSMA\PR3\Steinberger\SL2\Name.txt", "r")
|
||||
data = text_file.readlines()
|
||||
arr = [None] * len(data)
|
||||
counter = 1
|
||||
|
||||
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]
|
||||
|
||||
titel = re.search("^.*\.$",name_array[0])
|
||||
|
||||
|
||||
if titel != None:
|
||||
titel = titel.string
|
||||
if len(name_array) == 4:
|
||||
vorname = name_array[1]
|
||||
zweitname = name_array[2]
|
||||
nachname = name_array[3]
|
||||
else:
|
||||
vorname = name_array[1]
|
||||
nachname = name_array[2]
|
||||
zweitname = None
|
||||
else:
|
||||
if len(name_array) == 3:
|
||||
vorname = name_array[0]
|
||||
zweitname = name_array[1]
|
||||
nachname = name_array[2]
|
||||
else:
|
||||
vorname = name_array[0]
|
||||
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)
|
||||
# strasse = re.findall(r"\b[A-Z]",adresse)
|
||||
chars = re.split("\d",adresse)
|
||||
strasse = chars[0]
|
||||
ort = adresse_array[len(adresse_array)-1]
|
||||
|
||||
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,
|
||||
"Titel" : titel,
|
||||
"Vorname" : vorname,
|
||||
"Zweitname" : zweitname,
|
||||
"Nachname" : nachname,
|
||||
"Geburtsdatum" : geburtsdatum,
|
||||
"Strasse" : strasse,
|
||||
"Hausnummer" : hausnummer,
|
||||
"PLZ" : plz,
|
||||
"Wohnort" : ort,
|
||||
"Rufnummer" : telefon
|
||||
}
|
||||
|
||||
arr[counter - 1] = person
|
||||
counter = counter + 1
|
||||
|
||||
|
||||
with open(r"C:\Users\denni\Documents\Bundeswehr\HSMA\PR3\Steinberger\SL2\PersonNeu.json", "w") as f:
|
||||
json.dump(arr,f)
|
Loading…
Reference in New Issue