It's a pretty simple file format. This code parses the file into an list of dictionaries. It should be easy to save to a csv from there.
all_data = []
for line in f.readlines():
if line.strip() == "[TOP]":
# Start - create empty dictionary
line_data = {}
elif line.strip() == "[ENDTOP]":
# End - save dictionary to list
all_data.append(line_data)
else:
# Data - save to dictionary
data = line.split('=')
if len(data) == 2:
line_data[data[0]] = data[1].strip()
Produces:
[
{'Name': '1', 'Plic': '11', 'Glab': '5487', 'Gendr': '2261', 'Mars': '0'},
{'Name': '2', 'Plic': '13', 'Glab': '5556', 'Gendr': '2321', 'Mars': 'E'},
{'Name': '2', 'Plic': '55', 'Glab': '4012', 'Gendr': '3758', 'Mars': '2'}
]
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…