How can I extract the groups from this regex from a file object (data.txt)?
import numpy as np
import re
import os
ifile = open(\"data.txt\",\'r\')
# Regex
times = [match.group(1) for match in pattern.finditer(ifile.read())]
finditer yield MatchObjects. If the regex doesn't match anything times will be an empty list.
You can also modify your regex to use non-capturing groups for storeU, storeI, iIx and avgCI, then pattern.findall will contain only matched times.
Note: naming variable time might shadow standard library module. times would be a better option.