Report

class decida.Report.Report(filename, format=None, comment_char='#', verbose=False, csv=False)

synopsis:

Format and report data to file.

Report manages a reporting scheme where data is to be written to a file in column-oriented format.

The output format is space-separated values, but an additional comma-separated values format file can also be written.

The Report header method specifies the names of the data columns. After each set of values (one value for each data column) is written to the file, the file is flushed.

constructor arguments:

filename (str)

name of report file to generate.

format (str) (optional, default=None)

format string for report values. If None, then report items are formatted as float.

comment_char (str) (optional, default=”#”)

character(s) to prepend to comments.

verbose (bool, default=False)

if true, print each report line to stdout.

csv (bool, default=False)

if true, report to a csv file.

results:

  • if file already exists, move to file.bak
  • reports header, followed by reported lines, formated by the report format

example:

>>> from decida.Report import Report
>>> rpt = Report("example1.txt", verbose=True)
>>> rpt.header("time vscl")
>>> for i in range(0, 20):
>>>    t = i*1e-3/20
>>>    v = 1.2 + 2.4*t + 840.0*t*t
>>>    rpt.report(t, v)

public methods:

comment(comment)

generate a comment in the report file. no comments are placed in csv files.

comment (str)

comment string to put in report file, prepended with a comment-character (comment_char)
date()

generate a date/time comment in the report file. no comments are placed in csv files.

header(*args)

generate a header in the report file. if format is not specified, header is used to generate the format.

*args (str or lists of str)

separate or combined header column names the column names can be separate list items, specified in a string with space separated fields, or specified in a list of strings
report(*args)

generate a report line in the report file.

*args (items or lists of items)

items to report to the report file each argument can be a separate report item, or a list of report items. The combined list of report items is formatted by the specified Report format.
user()

generate a user comment in the report file. no comments are placed in csv files.