i have a txt file, which has the following structure
start
id=1
date=21.05.2018
summ=500
end
start
id=7
date=23.05.2018
summ=500
owner=guest
end
Easiest algorithm I could think of, if I get your question right.
d ={}
arr = []
for line in plines:
if line == 'start':
continue
elif line =='end':
arr.append(d)
continue
else:
list_key_value = line.split('=')
d[list_key_value[0]] = int(list_key_value[1]) if
type(list_key_value[1]) == 'int' else str(list_key_value[1])
print (arr)
Output:
[{'id': '7', 'date': '23.05.2018', 'summ': '500', 'owner': 'guest'},
{'id': '7', 'date': '23.05.2018', 'summ': '500', 'owner': 'guest'}]