Text File contents:
&CRB A='test1' B=123,345, 678 &END
Misc text potentially between entries ...
&CRB A='test2'
B=788, 345, 3424 &END
&CRB A='test3'
B=788, 345, 3424 &END
&CRB A='test4' B=788, 345, 3424 &END
What is the most efficient way to iterate through the entries between the keywords? Note
that some entries span lines. Something like the following is desired –
f = open(filename)
for entry in f:
- do something with entry
Of course it is not that easy. But, are there suggestions on a straightforward way to iterate thorough the entries delimiated by two key words.
Assuming that the entry is all of the text between
&CRBand&ENDpairs, you can pull out the text between them with something like this:prints this:
…it’s your problem to clean up and interpret the contents of each of those records…