get_line_col¶
-
get_line_col
(filename, skip_line=0, skip_col=0, col_sep=None, seek=0, encoding='utf-8')¶ Get a value at specific line/columns coordinates.
- Parameters
- filenamestr
The name of the file that will be parsed
- skip_lineint, default=0
Number of lines skipped If skip_line < 0: count lines backward from the end of the file. Be careful: a last empty line is taken into account too! Default: 0: no line skipped
- skip_colint, default=0
Number of columns skipped from the beginning or end of the line. If skip_col < 0: count col backward from the end of the line. Default: 0: no column skipped
- col_sepstr
Column separator Default: None: whitespace separator, see str.split
- seekint, default=0
if > 0, consider the file starts at pos seek. if < 0, consider the file ends at pos -seek (and NOT (end-(-seek))!). Default: 0: consider the whole file.
- encodingstr
File encoding see http://docs.python.org/2/library/codecs.html#codec-base-classes
- Returns
- resultfloat
Value to retrieve
Examples
>>> import openturns.coupling_tools as ct >>> with open('results.out', 'w') as f: ... count = f.write('1.1 1.2 1.3 1.4') >>> ct.get_line_col(filename='results.out', skip_col=2) 1.3