expyriment.io.InputFile

class expyriment.io.InputFile(filename, encoding=None)

A class implementing an input file.

__init__(filename, encoding=None)

Create an input file.

All lines in the specified text file will be read into a list of strings.

Parameters:
filenamestr, optional

name of the input file

encodingstr, optional

the encoding used to read the content of the file

property current_line

Getter for current_line.

property filename

Getter for filename.

get_line(line=None)

Get a specific line.

If no line is given, the current line will be returned and the value of current_line will be increased by one. First line is line 1.

Parameters:
lineint, optional

number of the line to get

Returns:
linestr

line as string or None if line does not exist

property lines

Getter for lines.

property logging

Getter for logging.

property n_lines

Getter for n_lines.

set_logging(onoff)

Set logging of this object on or off

Parameters:
onoffbool

set logging on (True) or off (False)