get¶
-
get
(filename, tokens=None, skip_tokens=None, skip_lines=None, skip_cols=None, encoding='utf-8')¶ 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
- filenamestr
The name of the file that will be parsed
- tokenslist of str
see get_value
- skip_tokenslist of int
see get_value
- skip_lineslist of int
see get_value()
- skip_colslist of int
see get_value()
- encodingstr
File encoding, see http://docs.python.org/2/library/codecs.html#codec-base-classes
- Returns
- resultlist of float
Values parsed
- Raises
- AssertionError
parameters badly set
- EOFError
no value found
Examples
using tokens
>>> import openturns.coupling_tools as ct >>> with open('results.out', 'w') as f: ... count = f.write('Y1=2.0, Y2=-6.6E2') >>> ct.get(filename='results.out', tokens=['Y1=', 'Y2=']) [2.0, -660.0]