get

get(filename, tokens=None, skip_tokens=None, skip_lines=None, skip_cols=None, encoding='ascii')

Get several values from a file using delimiters and/or offsets.

This is equivalent to get_value Each following parameters must be a list. The first element of each list will be used to get the first value, the 2nd … If the parameter is set to None, the list is set to the default value of get_value(), i.e skip_lines=None => [0, 0, …].

Parameters:

filename : str

The name of the file that will be parsed

tokens : list of str

see get_value

skip_tokens : list of int

see get_value

skip_lines : list of int

see get_value()

skip_cols : list of int

see get_value()

encoding : str

Returns:

result : list of float

Values parsed

Raises:

AssertionError

parameters badly set

EOFError

no value found

Examples

using tokens

>>> import openturns.coupling_tools as otct
>>> with open('results.out', 'w') as f:
...     count = f.write('Y1=2.0, Y2=-6.6E2')
>>> otct.get(filename='results.out', tokens=['Y1=', 'Y2='])
[2.0, -660.0]