I have the following text
Stat indicator : 01245 Values loaded
Some irrelevant data
Stat indicator : 13452 Values loaded
My output should be giving me numbers 01245, 13452
Heres what I have tried
with open('test.txt') as fd:
data = fd.read()
val_to_pattern = {'stat': r'Stat indicator : .{5}\n'}
val_dict = {}
for key, patt in val_to_pattern.items():
val_dict[key] = re.findall(patt, data)