I have a file on chemical compounds that gives the name of a section with the corresponding data, sometimes with a few lines of data, before it has a new section with a different name. I'm trying to read the 'NAME' entries (minus the 'NAME' part) and read each name (if it has multiple) into a list, then break whenever it reaches the 'FORMULA' section and have it move onto the next 'NAME' section, but I don't know how. I'm a novice programmer. Here's an example: Compound List Screenshot
Here's my code so far:
li=[] #list of all names
for line in inputFile:
if line[:5]=='ENTRY':
items = line.split()
cmNm = items[1] #compound Number
else line[:4]=='NAME':
items = line.split()
cmName = items[]
if line[:7]=='FORMULA':
break