| |
- get_dicts(csvfile, sep=',')
- csvfile: string, a filename of a csv file. The file should have a header
row with column names.
sep: string, the delimiter used to separate values in the csv file. Defaults
to comma.
Returns: lists (one for each row in the file) of dictionaries mapping
strings (column names) to strings (cell values).
- get_rows(csvfile, sep=',')
- csvfile: string, a filename of a csv file.
sep: string, the delimiter used to separate values in the csv file. Defaults
to comma.
Returns: lists (one for each row in the file) of lists (one for each cell in
the row) of strings.
- group_by_col(rows, column)
- rows: [[string]] (output of get_rows) or [{string: string}] (output of
get_dicts).
column: integer if [[string]], string if [{string: string}].
Returns: {column: rows}, a dictionary whose keys are the unique values in
the column provided, where each column value maps to a list of all rows with
that value.
- make_experiment(id_generator)
- id_generator: IDGenerator, an object that will make unique IDs for
everything in an Experiment.
side effect: puts id_generator in scope for the duration of the with block.
Options, Pages, and Blocks will automatically use it to create unique IDs.
Usage:
with make_experiment(IDGenerator()):
<experiment code>
<any code here will not use that IDGenerator anymore>
|