Newer
Older
.. algorithm::
.. summary::
.. alias::
.. properties::
Description
-----------
The workspace data are stored in the file in columns: the first column contains
the X-values, followed by pairs of Y and E values. Columns are separated by
commas. The resulting file can normally be loaded into a workspace by the
:ref:`algm-LoadAscii` algorithm.
Limitations
The algorithm assumes that the workspace has common X values for all spectra
(i.e. is not a `ragged workspace <Ragged Workspace>`__).
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
Usage
-----
**Example - Save a workspace in CSV format**
.. testcode:: ExSaveASCIISimple
#import the os path libraries for directory functions
import os
# create histogram workspace
dataX1 = [0,1,2,3,4,5,6,7,8,9] # or use dataX1=range(0,10)
dataY1 = [0,1,2,3,4,5,6,7,8] # or use dataY1=range(0,9)
dataE1 = [1,1,1,1,1,1,1,1,1] # or use dataE1=[1]*9
ws1 = CreateWorkspace(dataX1, dataY1, dataE1)
#Create an absolute path by joining the proposed filename to a directory
#os.path.expanduser("~") used in this case returns the home directory of the current user
savefile = os.path.join(os.path.expanduser("~"), "AsciiFile.txt")
# perform the algorithm
SaveAscii(InputWorkspace=ws1,Filename=savefile)
print "File Exists:", os.path.exists(savefile)
.. testcleanup:: ExSaveASCIISimple
os.remove(savefile)
Output:
.. testoutput:: ExSaveASCIISimple
File Exists: True
**Example - Save a workspace as ASCII with a different delimiter**
.. testcode:: ExSaveASCIIDelimiter
#import the os path libraries for directory functions
import os
# create histogram workspace
dataX1 = [0,1,2,3,4,5,6,7,8,9] # or use dataX1=range(0,10)
dataY1 = [0,1,2,3,4,5,6,7,8] # or use dataY1=range(0,9)
dataE1 = [1,1,1,1,1,1,1,1,1] # or use dataE1=[1]*9
ws1 = CreateWorkspace(dataX1, dataY1, dataE1)
#Create an absolute path by joining the proposed filename to a directory
#os.path.expanduser("~") used in this case returns the home directory of the current user
savefile = os.path.join(os.path.expanduser("~"), "AsciiFile.txt")
# perform the algorithm
SaveAscii(InputWorkspace=ws1,Filename=savefile,Separator="Space")
print "File Exists:", os.path.exists(savefile)
.. testcleanup:: ExSaveASCIIDelimiter
os.remove(savefile)
Output:
.. testoutput:: ExSaveASCIIDelimiter
File Exists: True
**Example - Save a workspace as ASCII with a different comment indicator**
.. testcode:: ExSaveASCIIComment
#import the os path libraries for directory functions
import os
# create histogram workspace
dataX1 = [0,1,2,3,4,5,6,7,8,9] # or use dataX1=range(0,10)
dataY1 = [0,1,2,3,4,5,6,7,8] # or use dataY1=range(0,9)
dataE1 = [1,1,1,1,1,1,1,1,1] # or use dataE1=[1]*9
ws1 = CreateWorkspace(dataX1, dataY1, dataE1)
#Create an absolute path by joining the proposed filename to a directory
#os.path.expanduser("~") used in this case returns the home directory of the current user
savefile = os.path.join(os.path.expanduser("~"), "AsciiFile.txt")
# perform the algorithm
# CommentIndicator can be changed, but when read back in must be specified
SaveAscii(InputWorkspace=ws1,Filename=savefile,CommentIndicator="!")
print "File Exists:", os.path.exists(savefile)
.. testcleanup:: ExSaveASCIIComment
os.remove(savefile)
Output:
.. testoutput:: ExSaveASCIIComment
File Exists: True
.. categories::