I have big text file which has lot of text information but I would like to extract the text between two defined text. e.g
/begin MEASUREMENT XYZ
UBYTE
_CNV_A_R_LINEAR_____71_CM
1
100.
-40.
160.
FORMAT "%3.0"
SYMBOL_LINK "XYZ" 0
/begin IF_DATA EVTRKMNBXERTBK
DEFAULT_RASTERS 3 3
/end IF_DATA
/end MEASUREMENT
i.e /begin MEASUREMENT and /end MEASUREMENT in between this I want to extract text.
My code is:
import re
path = r"d:\xyz.txt"
file = open(path, 'r')
lines = file.read()
pattern = re.compile(r'begin MEASUREMENT[\s][\w+](.*?)end MEASUREMENT')
print re.findall(pattern, lines)