2.7.13 impASC


Menu Information

File : Import : Single/Multiple ASCII...

This X-Function supports file re-import. See this topic for details.

Brief Description

Import ASCII file/files.

Additional Information

This feature was updated in Origin 8.5 SR0.

Command Line Usage

1. impASC fname:="c:\nitrogen.txt" options.sparklines:=0;

2. impasc fname:="c:\vartest1.dat%(crlf)c:\vartest2.dat" options.impmode:=4;

Variables

Display
Name
Variable
Name
I/O
and
Type
Default
Value
Description
File Name fname

Input

string

fname$
Specify the filename of the file to be imported.
Launch Option menu

Input

int

1
This variable is only for controlling menus, and is not actually used by this X-Function.


Option list:

  • single:&Single ASCII
    Single ASCII
  • multiple:&Multiple ASCII
    Multiple ASCII
File Info trfiles

Input

TreeNode

<unassigned>
This is used in the dialog for displaying basic file information. The information is automatically detected by Origin.
Import Options options

Input

TreeNode

<unassigned>
Specify the import options in the dialog. See more details in the Description section.
Output orng

Output

Range

<active>
Use this to specify the output range.

See the syntax documented here.

Header Info trheader

Output

TreeNode

<unassigned>
Output header information. This variable is for internal use only. Please do not use.
Import Filter trFilter

Input

TreeNode

<optional>
Specify the filter options in the dialog. This variable is for internal use only. Please do not use.
File Info Storage Index findex

Output

int

<optional>
Specify the index number for file information storage in the target workbook.
Repeat Import reimp

Input

int

0
Specify whether the current import is a reimporting process. Use of this variable is not advised.

Description

This function will import ASCII file/files by setting the options in the dialog. It can be accessed from menu, toolbar or command window.

When to use this function?

Origin now provides three tools for importing ASCII files: Import Wizard, Import Single ASCII, and Import Multiple ASCII.

Import Single ASCII and Import Multiple ASCII are most useful when you are familiar with the data structure of the file being imported.

If you do not have detailed knowledge of the file’s structure, the Import Wizard may be a better choice. The Import Wizard is powerful and versatile, and provides many import options, as well as a Preview pane for monitoring settings.

Options Tree Details

  • Import Options Tree
Please see the impASC Options Treenode Information page for details on the many import options available.

Examples

Because there are many options for importing an ASCII file, this function is most likely to be accessed through a dialog. However, it can be accessed from a script for automatically importing files. In this section, some simple examples are introduced for accessing impAsc from both dialog and script:

  • Access impASC through the dialog
The following steps show how to import a file by auto-determining header lines.
  1. Create a new workbook.
  2. Open the impASC dialog through one of these methods: type impASC -d; in the command window; click the Import Multiple ASCII button in the toolbar; or, in the main menu, click File, point to Import, and then click Multiple ASCII.
  3. Browse to the file you wish to import (in this case, <Origin Installation Folder>\Samples\Import and Export\S15-125-03.dat). Click OK.
  4. In the impASC dialog, click the arrow button next to Dialog Theme and select System Default.
  5. Under Import Options, expand the Header Lines node. Ensure that Auto Determine Subheader Lines is selected.
  6. Click OK to import the file. The file should be imported into the workbook, and the Long Name, Units, and Sparklines should be correctly set.
  • Access impASC from script

1. Basic usage

impASC fname:= system.path.program$+"Samples\Import and Export\S15-125-03.dat";

2. The following script will first use the X-Function dlgFile to open a dialog for browsing to a single file, and the file name will be stored in a string variable called fname$. ImpASC can then be used without specifying the parameter fname.

dlgFile;
impASC;

3. As impASC supports the import of multiple files, normally this function can be used together with the X-Function findFiles.

//set the data folder,
string path$ = system.path.program$+"Samples\Import and Export";
// you can also use dlgPath to browse the path for the folder, the path will be stored as path$
// dlgPath;
// navigate to the data folder
cd path$;
// find all files that match s*.dat
findFiles ext:=s*.dat;
// import the files
impASC;

Related X-Functions

impFile, impinfo, dlgPath, dlgFile, findFiles, cd