File : Import : Single/Multiple ASCII...
This X-Function supports file re-import. See this topic for details.
Import ASCII file/files.
This feature was updated in Origin 8.5 SR0.
1. impASC fname:="c:\nitrogen.txt" options.sparklines:=0;
2. impasc fname:="c:\vartest1.dat%(crlf)c:\vartest2.dat" options.impmode:=4;
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 |
---|---|---|---|---|
File Name | fname |
Input string |
|
Specify the filename of the file to be imported. |
Launch Option | menu |
Input int |
|
This variable is only for controlling menus, and is not actually used by this X-Function.
|
File Info | trfiles |
Input TreeNode |
|
This is used in the dialog for displaying basic file information. The information is automatically detected by Origin. |
Import Options | options |
Input TreeNode |
|
Specify the import options in the dialog. See more details in the Description section. |
Output | orng |
Output Range |
|
Use this to specify the output range.
See the syntax documented here. |
Header Info | trheader |
Output TreeNode |
|
Output header information. This variable is for internal use only. Please do not use. |
Import Filter | trFilter |
Input TreeNode |
|
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 |
|
Specify the index number for file information storage in the target workbook. |
Repeat Import | reimp |
Input int |
|
Specify whether the current import is a reimporting process. Use of this variable is not advised. |
This function will import ASCII file/files by setting the options in the dialog. It can be accessed from menu, toolbar or command window.
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.
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:
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. 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;