Text parsing and retrieval

For small files where the whole file can be easily loaded into memory, the following approach could be used:

import re

with open('input.txt', 'r') as f_input:
    print re.findall(r'ACTION TYPE: Insertion.*?TIME: (.*?)$', f_input.read(), re.M+re.S)

Which would display the following for your sample:

['2015-10-09 10.50.12', '2015-10-09 12.19.22']

Leave a Comment