Skip to content

Commit

Permalink
Re #9579. Added Usage section to SaveCSV.
Browse files Browse the repository at this point in the history
Added a correction to the mantid docs sphinx extension to deal with nonprintable characters in algorithm properties.
  • Loading branch information
mantid-roman committed Jun 9, 2014
1 parent 7f2986b commit b806c1c
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 11 deletions.
40 changes: 29 additions & 11 deletions Code/Mantid/docs/source/algorithms/SaveCSV-v1.rst
Expand Up @@ -11,20 +11,20 @@ Description

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

The format of the saved CSV file for a 2D workspace is as follows:
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``
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``
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
Expand All @@ -37,4 +37,22 @@ 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
-----

.. testcode::

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)

.. testcleanup::

os.remove(filePath)

.. categories::
5 changes: 5 additions & 0 deletions Code/Mantid/docs/sphinxext/mantiddoc/directives/properties.py
Expand Up @@ -140,6 +140,11 @@ def _create_property_default_string(self, prop):
# Fall-back default for anything
defaultstr = str(default)

# replace nonprintable characters with their printable
# representations, such as \n, \t, ...
defaultstr = repr(defaultstr)[1:-1]
defaultstr = defaultstr.replace('\\','\\\\')

# Replace the ugly default values with "Optional"
if (defaultstr == "8.9884656743115785e+307") or \
(defaultstr == "1.7976931348623157e+308") or \
Expand Down

0 comments on commit b806c1c

Please sign in to comment.