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

SaveCSV v1

../_images/SaveCSV-v1_dlg.png

SaveCSV dialog.

Summary

Saves a 1D or 2D workspace to a CSV file.

See Also

SaveAscii

Properties

Name

Direction

Type

Default

Description

InputWorkspace

Input

MatrixWorkspace

Mandatory

The filename of the output CSV file

Filename

Input

string

Mandatory

The name of the workspace containing the data you want to save to a CSV file. Allowed extensions: [‘.csv’]

Separator

Input

string

,

The separator that will go between the numbers on a line in the output file (default ‘,’)

LineSeparator

Input

string

\n

The string to place at the end of lines (default new line character)

SaveXerrors

Input

boolean

False

This option saves out the x errors if any are present. If you have x errors in your workspace and you do not select this option, then the x errors are not saved to the file.

Description

The format of the saved ascii CSV file for a 1D worksspace consists of three columns where the numbers of each row are separated by the Separator and each line by the LineSeparator.

The format of the saved CSV file for a 2D workspace is as follows:

 A      0, 200, 400, 600, ..., 50000
 0     10,   4, 234,  35, ...,    32
 1      4, 234,   4,   9, ...,    12
 A      0, 100, 200, 300, ..., 25000
 2     34,   0,   0,   0, ...,    23

ERRORS
 0    0.1, 3.4, 2.4, 3.5, ...,     2
 1    3.1, 3.3, 2.5, 3.5, ...,     2
 2    1.1, 3.3, 2.4,   5, ...,   2.4

where for the matrix above the ERRORS line the first column shows the content of the numbers on the of the same line; i.e. ‘A’ is followed by x-axis values (e.g. TOF values) and any number (e.g. ‘2’) followed by y-axis values (e.g. neutron counts). Multiple ‘A’ may be present to allow for the a-axis to change. So in the example above the saved 2D workspace consists of three histograms (y-axes) where the first two have the same x-axis but the third histogram has a different x-axis.

The matrix following the ERRORS line lists the errors as recorded for each histogram.

Usage

import os
# Create a file path in the user home directory
filePath = os.path.expanduser('~/SavedCSVFile.csv')

# Create a workspace
ws=CreateSampleWorkspace()
# Save it in Nexus format
SaveCSV(ws,filePath)

Categories: AlgorithmIndex | DataHandling\Text

Source

C++ header: SaveCSV.h

C++ source: SaveCSV.cpp