# Results class

class pymeasure.experiment.results.CSVFormatter(columns, delimiter=',')

  Formatter of data results

  format(record)

    Formats a record as csv.

    Parameters:

      record (dict) – record to format.

    Returns:

      a string

class pymeasure.experiment.results.Results(procedure, data_filename)

  The Results class provides a convenient interface to reading and writing data in connection with a `Procedure` object.

  Variables:

    - COMMENT – The character used to identify a comment (default: #)

    - DELIMITER – The character used to delimit the data (default: ,)

    - LINE_BREAK – The character used for line breaks (default n)

    - CHUNK_SIZE – The length of the data chuck that is read

  Parameters:

    - procedure – Procedure object

    - data_filename – The data filename where the data is or should be stored

  format(data)

    Returns a formatted string containing the data to be written to a file

  header()

    Returns a text header to accompany a datafile so that the procedure can be reconstructed

  labels()

    Returns the columns labels as a string to be written to the file

  static load(data_filename, procedure_class=None)

    Returns a Results object with the associated Procedure object and data

  metadata()

    Returns a text header for the metadata to write into the datafile

  parse(line)

    Returns a dictionary containing the data from the line

  static parse_header(header, procedure_class=None)

    Returns a Procedure object with the parameters as defined in the header text.

  reload()

    Preforms a full reloading of the file data, neglecting any changes in the comments

  store_metadata()

    Inserts the metadata header (if any) into the datafile

pymeasure.experiment.results.replace_placeholders(string, procedure, date_format='%Y-%m-%d', time_format='%H:%M:%S')

  Replace placeholders in string with values from procedure parameters.

  Replaces the placeholders in the provided string with the values of the associated parameters, as provided by the procedure. This uses the standard python string.format syntax. Apart from the parameter in the procedure (which should be called by their full names) “date” and “time” are also added as optional placeholders.

  Parameters:

    - string – The string in which the placeholders are to be replaced. Python string.format syntax is used, e.g. “{Parameter Name}” to insert a FloatParameter called “Parameter Name”, or “{Parameter Name:.2f}” to also specifically format the parameter.

    - procedure – The procedure from which to get the parameter values.

    - date_format – A string to represent how the additional placeholder “date” will be formatted.

    - time_format – A string to represent how the additional placeholder “time” will be formatted.

pymeasure.experiment.results.unique_filename(directory, prefix='DATA', suffix='', ext='csv', dated_folder=False, index=True, datetimeformat='%Y-%m-%d', procedure=None)

  Returns a unique filename based on the directory and prefix