2.7.5 expASC

Menu Information

File : Export : ASCII

Brief Information

Export worksheet data as ASCII file

Command Line Usage

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";

X-Function Execution Options

Please refer to the page for additional option switches when accessing the x-function from script

Variables

Display
Name
Variable
Name
I/O
and
Type
Default
Value
Description
Input Worksheet iw

Input

Worksheet

<active>
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

0
Specify the extension of the exported file.

Option list:

  • dat:*.dat {0}
    Export the ASCII data as a .dat file.
  • text:Text File(*.txt) {1}
    Export the ASCII data as a .txt file
  • csv:*.csv {2}
    Export the ASCII data as a .csv file.
  • all:All Files(*.*) {3}
    Export the ASCII data to file name exactly as specified by the user.

When you use .dat, .txt or .csv, that extension is added to the specified filename extension unless they match.

File Path path

Input

string

fname$
Specify the path and filename of output file.
Encoding encoding

Input

int

0
Specify the encoding method of the exported file.

Option list:

  • auto:Auto (0),
  • ansi:ANSI (1),
  • utf8:UTF-8 (2),
  • utf16le:Unicode (3),
  • utf16be:Unicode Big Endian (4)

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

2
Specify whether to overwrite the existing file if there is an file with the same name as the exported file.

Option list:

  • replace:Replace {0}
    Replace the data in the existing file with the exported data.
  • append:Append {1}
    Append the exported data to the existing file.

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

0
When this checkbox is selected, only the selected data will be exported. Note that the selection can be non-contiguous.
Separator separator

Input

int

0
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:

  • tab:TAB {0}
    Use Tab for delimiter.
  • comma:, {1}
    Use comma for delimiter.
  • space:SPACE {2}
    Use space for delimiter.
  • ct:,TAB {3}
    Use comma and Tab for delimiter.
  • cs:,SPACE {4}
    Use comma and space for delimiter.
Separator csvsep

Input

int

Comma

When the file type is CSV, this parameter sets separator to comma or semicolon.


Option list

  • Comma
    Use comma for delimiter.
  • Semicolon
    Use semicolon for delimiter.
Include Short Name shortname

Input

int

0
Specify whether the Short name heading row will be exported.
Include Long Name longname

Input

int

1
Specify whether the Long name heading row will be exported.
Include Units units

Input

int

1
Specify whether the Unit heading row will be exported.
Include Comments comment

Input

int

1
Specify whether the Comments heading row will be exported.
Include User Parameters userparam

Input

int

0
Specify whether the User Parameters rows will be exported.
Include Sampling Interval sampinterv

Input

int

0
Specify whether the Sampling interval heading row will be exported.
Include Parameters parameter

Input

int

0
Specify whether the Parameter heading row will be exported.
Include Row Labels and Index rowlabel

Input

int

0
Specify whether the row labels and index numbers will be exported.
Export with Full Precision precision

Input

int

1
Specify whether data should be exported with full precision. The default value is true.
Export Sampling Interval as New Column addxcol

Input

int

0
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

1
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.

Description

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.

Examples

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
            };
}

Related X-Functions

impASC, expMatASC, expPDFw