\(\renewcommand\AA{\unicode{x212B}}\)

CreateEmptyTableWorkspace v1

../_images/ImageNotFound.png

Enable screenshots using DOCS_SCREENSHOTS in CMake

Summary

Creates an empty TableWorkspace which can be populated with various types of information.

See Also

DeleteTableRows, SortTableWorkspace

Properties

Name

Direction

Type

Default

Description

OutputWorkspace

Output

TableWorkspace

Mandatory

The name of the table workspace that will be created.

Description

Creates an empty table workspace, which you can then populate with items of various types.

For a complete list of TableWorkspace methods accessible from Python please see the ITableWorkspace.

Usage

Example - Creating and Populating a Table

my_table = CreateEmptyTableWorkspace()

my_table.setTitle("My Data List")

my_table.addColumn("str", "Instrument Name")
my_table.addColumn("int", "Run Number")

my_table.addRow(["MUSR", 10245])
my_table.addRow(["IRIS", 8465])
my_table.addRow(["SANS2D", 20462])

print("The run number for IRIS is {}.".format(my_table.cell("Run Number", 1)))
print("The number of rows is {}.".format(my_table.rowCount()))
print("The title of the table is {}.".format(my_table.getTitle()))
print("Remember, the table is a workspace.  It's name is \"{}\".".format(my_table.name()))

Output:

The run number for IRIS is 8465.
The number of rows is 3.
The title of the table is My Data List.
Remember, the table is a workspace.  It's name is "my_table".

Categories: AlgorithmIndex | Utility\Workspaces

Source

Python: CreateEmptyTableWorkspace.py