def csv_export(self, rows, view, group_cells, cells): output_csv_headers(view) groups, unique_row_ids, matrix_cells = list( create_matrices(rows, group_cells, cells, num_columns=None))[0] value_counts, _row_majorities = self._matrix_find_majorities( rows, cells) painter_options = PainterOptions.get_instance() with table_element(output_format="csv") as table: for cell_nr, cell in enumerate(group_cells): table.row() table.cell("", cell.title(use_short=False)) for _group, group_row in groups: _tdclass, content = cell.render(group_row) table.cell("", content) for rid in unique_row_ids: # Omit rows where all cells have the same values if painter_options.get("matrix_omit_uniform"): at_least_one_different = False for counts in value_counts[rid].values(): if len(counts) > 1: at_least_one_different = True break if not at_least_one_different: continue table.row() _tdclass, content = cells[0].render( list(matrix_cells[rid].values())[0]) table.cell("", content) for group_id, group_row in groups: table.cell("") cell_row = matrix_cells[rid].get(group_id) if cell_row is not None: for cell_nr, cell in enumerate(cells[1:]): _tdclass, content = cell.render(cell_row) if cell_nr: html.write_text(",") html.write_text(content)
def _export_csv_export(view: "View", rows: Rows) -> None: output_csv_headers(view.spec) CSVRenderer().show(view, rows)