File : Export : ASCII
Export worksheet data as ASCII file
1. expASC path:="c:\signal.dat";
2. expASC type:=csv path:="c:\signal";
3. expASC type:=dat path:="c:\signal" select:=1 separator:=cs;
4. expASC iw:=[book1]1 path:="c:\signal.dat";
Please refer to the page for additional option switches when accessing the x-function from script
Display Name |
Variable Name |
I/O and Type |
Default Value |
Description |
---|---|---|---|---|
Input Worksheet | iw |
Input Worksheet |
|
Specify the worksheet to be exported. By default, the active worksheet is sued. This value cannot be changed in the dialog box. |
File Type | type |
Input int |
|
Specify the extension of the exported file.
Option list:
When you use .dat, .txt or .csv, that extension is added to the specified filename extension unless they match. |
File Path | path |
Input string |
|
Specify the path and filename of output file. |
Encoding | encoding |
Input int |
|
Specify the encoding method of the exported file.
Option list:
Note: when auto is choosen, the file will first be exported as UTF-8, then it will be inspected whether it can be converted to MBCS using the current code page. If yes, it will be converted, otherwise left it as UTF-8. |
Overwrite Existing | overwrite |
Input int |
|
Specify whether to overwrite the existing file if there is an file with the same name as the exported file.
Option list:
If you use a value of 2 and the file exists you are presented with a dialog where you can choose to Replace, Append or rename the output file. |
Export Selected Data Only | select |
Input int |
|
When this checkbox is selected, only the selected data will be exported. Note that the selection can be non-contiguous. |
Separator | separator |
Input int |
|
Specify the character used as separator or delimiter. This control is not available when File Type is set to CSV. In that case, comma will be used for separator unless overridden by the csvsep option.
Option list:
|
Separator | csvsep |
Input int |
|
When the file type is CSV, this parameter sets separator to comma or semicolon.
|
Include Short Name | shortname |
Input int |
|
Specify whether the Short name heading row will be exported. |
Include Long Name | longname |
Input int |
|
Specify whether the Long name heading row will be exported. |
Include Units | units |
Input int |
|
Specify whether the Unit heading row will be exported. |
Include Comments | comment |
Input int |
|
Specify whether the Comments heading row will be exported. |
Include User Parameters | userparam |
Input int |
|
Specify whether the User Parameters rows will be exported. |
Include Sampling Interval | sampinterv |
Input int |
|
Specify whether the Sampling interval heading row will be exported. |
Include Parameters | parameter |
Input int |
|
Specify whether the Parameter heading row will be exported. |
Include Row Labels and Index | rowlabel |
Input int |
|
Specify whether the row labels and index numbers will be exported. |
Export with Full Precision | precision |
Input int |
|
Specify whether data should be exported with full precision. The default value is true. |
Export Sampling Interval as New Column | addxcol |
Input int |
|
Specify whether to add a new time column to the output data for each column that has a sampling interval. |
Export Missing Values as "--" | missing |
Input int |
|
Specify whether to export missing values as the "--" string. |
Ignore Ending Empty Columns | empty | int | 0 | Specify whether ignore the ending empty columns. When check this check box, the export will ignore all empty columns after the last column with data, meta data not considered, and column with all missing values are considered empty. |
Suffix for numbers in text cell | suffix |
Input string |
|
You can add suffix for numeric numbers in text columns. If you wish to do so (export phone and zip code for example), use this variable to specify the suffix. |
The expASC function exports worksheet data as ASCII file.
Note that the ASCII export is limited to data-only worksheets. Complex documents containing embedded information -- report sheets, worksheets with embedded or linked graphs (including sparklines) -- cannot be exported to ASCII files. If the worksheet to be exported has embedded images and graphs, those images and graphs will be ignored during exporting.
This example is to export all sheets in all workbooks within the project to a specified navigated path and name those data files as "WorkbookName_WorksheetName".
fdlog.openpath(B); // choose directory to store files doc -e W{ // loop over all workbooks in project doc -e LW // loop over all worksheets in workbook { string temp$ = wks.name$; // Get worksheet short name // string temp$ = wks.longname$; // Run this line to get worksheet long name expASC type:=text path:=%B%H_%(temp$) shortname:=1; // Export files as .txt files with column short names exported }; }
A variation on this example exports all worksheet columns to .dat files and organizes them using the project's Project Explorer folder structure:
string fname$ = "%YMap Data.opju"; doc -o %(fname$); // opens project User Files\Map Data.opju doc -e W{ // loop over all workbooks in project doc -e LW // loop over all worksheets in workbook { string temp$ = wks.name$; // Get worksheet short name // string temp$ = wks.longname$; // Run this line to get worksheet long name expASC path:="<Project Folder><PE Path>%(temp$)" shortname:=1; // Export and organize files using PE folder structure }; }