psychopy_ext.exp.Datafile

class psychopy_ext.exp.Datafile(filename, writeable=True, header=None)[source]

A convenience class for managing data files.

Output is recorded in a comma-separeated (csv) file.

Note

In the output file, floats are formatted to 1 ms precision so that output files are nice.

Args:
filename (str)

Path to the file name

Kwargs:
  • writeable (bool, defualt: True)

    Can data be written in file or not. Might seem a bit silly but it is actually very useful because you can create a file and tell it to write data without thinking whether no_output is set.

  • header (list, default: None)

    If you give a header, then it will already be written in the datafile. Usually it’s better to wait and write it only when the first data line is available.

__init__(filename, writeable=True, header=None)[source]

A convenience class for managing data files.

Output is recorded in a comma-separeated (csv) file.

Note

In the output file, floats are formatted to 1 ms precision so that output files are nice.

Args:
filename (str)

Path to the file name

Kwargs:
  • writeable (bool, defualt: True)

    Can data be written in file or not. Might seem a bit silly but it is actually very useful because you can create a file and tell it to write data without thinking whether no_output is set.

  • header (list, default: None)

    If you give a header, then it will already be written in the datafile. Usually it’s better to wait and write it only when the first data line is available.

Methods

__init__(filename[, writeable, header]) A convenience class for managing data files.
close() Closes the file
open() Opens a csv file for writing data
write(data) Writes data list to a file.
write_header(header) Determines if a header should be writen in a csv data file.