„SL2/s2_a3.py“ ändern

Main
Dennis Krämer 2023-01-12 12:50:06 +01:00
parent 588529032e
commit fc34a84e3b
1 changed files with 58 additions and 56 deletions

View File

@ -4,12 +4,13 @@ import string
text_file = open(r"Personen.txt", "r") text_file = open(r"Personen.txt", "r")
data = text_file.readlines() data = text_file.readlines()
arr = [None] * len(data) arr = [None] * len(data)
counter = 1 counter = 1
text_file.close() text_file.close()
for line in data: for line in data:
try:
data_array = re.split(",", line) data_array = re.split(",", line)
name = data_array[0] name = data_array[0]
name_array = re.split("\s",name) name_array = re.split("\s",name)
@ -72,7 +73,8 @@ for line in data:
arr[counter - 1] = person arr[counter - 1] = person
counter = counter + 1 counter = counter + 1
print(counter) except:
continue
with open(r"PersonenNeu.json", "w") as f: with open(r"PersonenNeu.json", "w") as f:
json.dump(arr,f, indent=1, ensure_ascii=False) json.dump(arr,f, indent=1, ensure_ascii=False)