get_regex

get_regex(filename, patterns, encoding='ascii')

Get results from a file using regex.

Parameters:

filename : str, the file to parse

patterns : list, patterns that will permit to get the values

see https://docs.python.org/2/library/re.html for available patterns The value to be searched must be surrounded by parenthesis.

encoding : str, file encoding

Returns:

results : list, values corresponding to each pattern

If nothing has been found, the corresponding value is set to None.

Raises:

AssertionError

parameters badly set

EOFError

no value found

Examples

>>> ## simple (results.out = '@E=-9.5E8')
>>> #Y = get_regex(filename='results.out',patterns=['@E=(\R)'])
>>> ## Y = [-9.5E8]