SaveTableCopy
SaveTableCopy [/A=a /I/M=termStr /N=n /O/P=pathName /S=s /T=saveType /F=f /W=winName /Z ] [as fileNameStr ]
The SaveTableCopy operation saves a copy of the data displayed in a table on disk. The saved file can be an Igor packed experiment file, a tab-delimited text file, or a comma-separated values text file.
When saving as text, by default the data format matches the format shown in the table. This causes truncation if the underlying data has more precision than shown in the table. If you specify /F=1, SaveTableCopy uses as many digits as needed to represent the data with full precision.
The point column is never saved.
When saving 3D and 4D waves as text, only the visible layer is saved. To save the entirety of a 3D or 4D wave, use the Save operation.
Parameters
The file to be written is specified by fileNameStr and /P=pathName where pathName is the name of an Igor symbolic path. fileNameStr can be a full path to the file, in which case /P is not needed, a partial path relative to the folder associated with pathName, or the name of a file in the folder associated with pathName. If Igor cannot determine the location of the file from fileNameStr and pathName, it displays a dialog allowing you to specify the file.
If you use a full or partial path for fileNameStr, see Path Separators for details on forming the path.
Flags
| /A=a | Appends data to the file rather than overwriting. | ||||||||||
| |||||||||||
| /A applies when saving text files and is ignored when saving packed experiment files. | |||||||||||
| If the file does not exist, a new file is created and /A has no effect. | |||||||||||
| /COMP={minWaveElements, gzipLevel, shuffle} | |||||||||||
| Specifies that compression is to be applied to numeric waves saved when saving as an HDF5 packed experiment file. The /COMP flag was added in Igor Pro 9.00. | |||||||||||
| minWaveElements is the minimum number of elements that a numeric wave must have to be eligible for compression. Waves with fewer than this many total elements are not compressed. | |||||||||||
| gzipLevel is a value from 0 to 9. 0 means no GZIP compression. | |||||||||||
| shuffle is 0 to turn shuffle off or 1 to turn shuffle on. | |||||||||||
| When compression is applied by SaveTableCopy, the entire wave is saved in one chunk. See HDF5 Layout Chunk Size for background information and SaveExperiment Compression for details. | |||||||||||
| /F=f | Controls the precision of saved numeric data when writing as text. | ||||||||||
| |||||||||||
| The /F flag was added in Igor Pro 7.00. | |||||||||||
| /I | Presents a dialog from which you can specify file name and folder. | ||||||||||
| /M=termStr | Specifies the terminator character or characters to use at the end of each line of text. The default is /M="\r\n"; it is used when /M is omitted. To use the Unix convention, just a linefeed, specify /M="\n". | ||||||||||
| /N=n | Specifies whether to use column names, titles, or dimension labels. | ||||||||||
| n is a bitwise parameter with the bits defined as follows: | |||||||||||
| |||||||||||
| The default setting for n is 1. | |||||||||||
| All other bits are reserved and must be zero. | |||||||||||
| /O | Overwrites file if it exists already. | ||||||||||
| /P=pathName | Specifies the folder to store the file in. pathName is the name of an existing symbolic path. | ||||||||||
| /S=s | Saves all of the data in the table (s =0; default) or the selection only (s =1) | ||||||||||
| /S applies when saving text files and is ignored when saving packed experiment files. | |||||||||||
| /T=saveType | Specifies the file format of the saved file. | ||||||||||
| |||||||||||
| /W= winName | winName is the name of the table to be saved. If /W is omitted or if winName is "", the top table is saved. | ||||||||||
| /Z | Errors are not fatal and error dialogs are suppressed. See Details. | ||||||||||
Details
The main uses for saving as a packed experiment are to save an archival copy of data or to prepare to merge data from multiple experiments (see Merging Experiments). The resulting experiment file preserves the data folder hierarchy of the waves displayed in the table starting from the "top" data folder, which is the data folder that encloses all waves displayed in the table. The top data folder becomes the root data folder of the resulting experiment file. Only the table and its waves are saved in the packed experiment file, not variables or strings or any other objects in the experiment.
SaveTableCopy does not know about dependencies. If a table contains a wave, wave0, that is dependent on another wave, wave1 which is not in the table, SaveTableCopy will save wave0 but not wave1. When the saved experiment is open, there will be a broken dependency.
The main use for saving as a tab or comma-delimited text file is for exporting data to another program.
When calling SaveTableCopy from a procedure, you should call DoUpdate before calling SaveTable copy. This insures that the table is up-to-date if your procedure has redimensioned or otherwise changed the number of points in the waves in the table.
SaveTableCopy sets the variable V_flag to 0 if the operation completes normally, to -1 if the user cancels, or to another nonzero value that indicates that an error occurred. If you want to detect the user canceling an interactive save, use the /Z flag and check V_flag after calling SaveTableCopy.
The SaveData operation also has the ability to save a table to a packed experiment file. SaveData is more complex but a bit more flexible than SaveTableCopy.
Examples
This function saves all tables to a single tab-delimited text file.
Function SaveAllTablesToTextFile(pathName, fileName)
String pathName // Name of an Igor symbolic path.
String fileName
String tableName
Variable index
index = 0
do
tableName = WinName(index, 2)
if (strlen(tableName) == 0)
break
endif
SaveTableCopy/P=$pathName/W=$tableName/T=1/A=1 as fileName
index += 1
while(1)
End