grid

Description

syside grid — export table and matrix views as RFC-4180 CSV.

A table or matrix view is a grid view, which is what the names here are built from; GridViewKind says what makes a view one.

write_csv exports from a model that is already loaded and returns a GridExportReport. The syside grid export command line does the same thing for a list of files, and prints what it did.

Index

Classes

ExportedGridView

One view that was written to disk.

GridExportReport

What write_csv() did.

GridViewExportError

Raised when rendering or writing one view failed.

GridViewsNotFoundError

Raised when a name in qualified_names exported nothing.

SkippedGridView

One view whose rows are in no file of this export, and why.

Functions

write_csv

Write the model’s table and matrix views to output_dir as RFC-4180 CSV.

Enumerations

GridSkipReason

Why a view in the model produced no CSV.

GridViewKind

What a view was classified as.


Functions

write_csv(model: syside.Model, output_dir: str | os.PathLike[str], *, qualified_names: Iterable[str | syside.QualifiedName] | None = None, bom: bool = False, max_file_name_length: int = 100) → syside.grid.GridExportReport

Write the model’s table and matrix views to output_dir as RFC-4180 CSV.

One file per view, named as syside grid export names them: table-<name>.csv or matrix-<name>.csv, built from the view’s qualified name – every character that is not a letter, a digit, _ or - replaced by _, segment by segment, joined with __. A view with no qualified name is named by its display name (a view named inside an unnamed package has one), and anonymous is the fallback for a view with neither. No two views share a file: on the rare occasion that two qualified names reduce to one name, all but the first are numbered apart (table-Pkg__View-2.csv) – which the report does not say in so many words, though the paths show it.

A view’s file name is a property of that view, so exporting the same model twice rewrites the same files. Renaming or moving a view renames its file, and the file written under the old name stays where it is – nothing here removes a file it did not write.

Parameters:
  • model – A model, loaded by syside.load_model or syside.try_load_model. Nothing is exported unless it is clean: any Error or Warning diagnostic refuses the whole export.

  • output_dir – Where to write. Created if it does not exist, including parents.

  • qualified_names – Export only these views, named as syside.QualifiedName.`None` and an empty iterable exports every table and matrix view in the model.

  • bom – Prefix each file with a UTF-8 byte-order mark, for spreadsheet software that needs one to read UTF-8.

  • max_file_name_length – The longest file name to write, in characters (16 to 255). Only the view’s own name is shortened to fit; the table-/matrix- prefix, the number that keeps two shortened names apart and .csv are always kept.

Returns:

What was written and what was skipped.

Raises:
  • syside.ModelError – The model carries an Error or Warning diagnostic.

  • TypeError – model is not a syside.Model, bom is not a bool, max_file_name_length is not an int, qualified_names is a single string rather than an iterable of them, or one of its items is neither a str nor a syside.QualifiedName.

  • ValueError – output_dir is an empty path, a name in qualified_names is an invalid qualified name, or max_file_name_length is outside 16 to 255.

  • GridViewsNotFoundError – A name in qualified_names exported nothing. Every other selected view has been written by then, so output_dir holds part of the export.

  • GridViewExportError – One view failed to render or write. The views enumerated before it have been written – the error carries them – and the failing view’s own file is left as it was, a failure part-way through a matrix included.

  • RuntimeError – output_dir could not be created or resolved.

Enumerations

class GridSkipReason

Why a view in the model produced no CSV.

Why a view in the model produced no CSV.

Why a view in the model produced no CSV.

Why a view in the model produced no CSV.

class GridViewKind

What a view was classified as.

A view is a grid view when it specialises one of the view definitions the SysideViews library declares – TableViewDefinitions::TableView or HierarchicalTableView, MatrixViewDefinitions::MatrixView or EditableMatrixView. Everything else is OTHER, including a view that specialises the SysML standard library’s own GridView, which is not one of these.

What a view was classified as.

A view is a grid view when it specialises one of the view definitions the SysideViews library declares – TableViewDefinitions::TableView or HierarchicalTableView, MatrixViewDefinitions::MatrixView or EditableMatrixView. Everything else is OTHER, including a view that specialises the SysML standard library’s own GridView, which is not one of these.

What a view was classified as.

A view is a grid view when it specialises one of the view definitions the SysideViews library declares – TableViewDefinitions::TableView or HierarchicalTableView, MatrixViewDefinitions::MatrixView or EditableMatrixView. Everything else is OTHER, including a view that specialises the SysML standard library’s own GridView, which is not one of these.

What a view was classified as.

A view is a grid view when it specialises one of the view definitions the SysideViews library declares – TableViewDefinitions::TableView or HierarchicalTableView, MatrixViewDefinitions::MatrixView or EditableMatrixView. Everything else is OTHER, including a view that specialises the SysML standard library’s own GridView, which is not one of these.

What a view was classified as.

A view is a grid view when it specialises one of the view definitions the SysideViews library declares – TableViewDefinitions::TableView or HierarchicalTableView, MatrixViewDefinitions::MatrixView or EditableMatrixView. Everything else is OTHER, including a view that specialises the SysML standard library’s own GridView, which is not one of these.

What a view was classified as.

A view is a grid view when it specialises one of the view definitions the SysideViews library declares – TableViewDefinitions::TableView or HierarchicalTableView, MatrixViewDefinitions::MatrixView or EditableMatrixView. Everything else is OTHER, including a view that specialises the SysML standard library’s own GridView, which is not one of these.