2.16.3.5 Details of TreeNodes in Import ASCII


Options

The Options tree specifies all import options for impAsc X-Function and some of the Options tree nodes are general for other X-Functions.

Syntax: Options.Treenode:=<value>

Example: Options.sparklines:=0

Treenode Label Type Default Description
sparklines Add Sparklines int 2 Specify whether to add sparklines for the data. Option list:
  • 0: No
    Do not add sparklines.
  • 1: Yes
    Add sparklines.
  • 2: Yes(if less than 50 columns)
    Add sparklines if there are less than 50 columns.
FirstMode 1st File Import Mode int 0 Specify the import mode of the first file. Option list:
  • 0: Replace Existing Data
    The data existing in the target window will be deleted, and the new data will be imported.
  • 1: Start New Columns
    Append new columns to the target worksheet for the imported file.
  • 2: Start New Rows
    Append new rows to the target worksheet for the imported file.
  • 3: Start New Books
    Create a new book for the file that that will be imported.
  • 4: Start New Sheets
    Create a new sheet for the file that will be imported.
Mode Multi-File (except 1st) Import Mode int 3 Specify the import mode of multiple files except the first one. Option list:
  • 1: Start New Columns
    Append new columns to the target worksheet for the imported file.
  • 2: Start New Rows
    Append new rows to the target worksheet for the imported file.
  • 3: Start New Books
    Create a new book for the file that that will be imported.
  • 4: Start New Sheets
    Create a new sheet for the file that will be imported.
PageTemplate Template Name String <default> Specify the template to import the file to a new book or new sheet. This option is available when the Import Mode is set to Replace Existing Data, Start New Sheets or Start New Books. By default, an Origin prototype workbook template <default> is used. A special template named <clone> is also available from the drop-down list which uses active workbook as the template to import files into the duplications of current worksheet/workbook.

Headers

The Headers branch of the Options tree specifies the header information of the imported file.

Syntax: Options.Headers.Treenode:= <value>

Example: Options.Headers.LongName:= 1

Treenode Label Type Default Description
AutoSubHeaderLines Auto Determine Header Lines int 1 Select this check box to have Origin automatically determine the number of header lines, main header lines and subheader lines. Note that it does not determine the structure of the subheader lines (e.g., which line is for long names and which is for units). If you want to manually specify the number, clear this check box.
ByBottom Line Number Start From Bottom int 0 With this selected, Origin will count up from the bottom of the subheader section for line numbers for Short Names, Long Names, Units, Comments From/To, Parameters From/To, and User Parameters From/To.
CountHeaderLines Main Header Lines int 0 Some files, particularly those generated by lab instrumentation, contain header information identfying, for example, the instrument, operator, date, and sample number. These are the main header lines. With this radio control, you can specify how to determine the main header lines.

0=Enter number to specify the number of main header lines.
1=Enter leading characters to detect the main header lines. This control is available since Origin 2018b.

MainHeaderLines Input Number int 0 Enter the number of the main header lines. This option is available when Main Header Lines is set to Fixed Number(CountHeaderLines=0).
HeaderLeadingChar Input Leading Character str Enter the leading characters to detect the main header lines which started with the characters you entered. This option is available when Main Header Lines is set to By Leading Character(CountHeaderLines=1).
SubHeaderLines Number of Subheader Lines int 0 This control is available only when the Auto Determine Subheader Lines check box is not checked. It is used to specify the number of subheader lines in the file.
LongName Long Names int 1 Specify the line for long names.
Unit Units int 2 Specify the line for units.
CommentFrom Comments From int 3 Specify the line from which the comments start.
CommentTo Comments to int 15 Specify the line at which the comments end.
ParametersFrom System Parameters From int 0 Specify the line from which the system parameters start.
ParametersTo System Parameters To int 0 Specify the line at which the system parameters end.
UserParametersFrom User Parameters From int 0 Specify the line from which the user parameters start.
UserParametersTo User Parameters To int 0 Specify the line at which the user parameters end.
Oneline Composite Header Line No. ORG-16802 int 0 If the import file header has names and units on the same line (e.g. Wavelength (nm), Intensity (a.u.)), use this variable to extract Long Nmae and Unite/Comment from this line. It specifies the row index of the composite header line.
OneLine Expression Composite Pattern string <auto> Avaiable when Oneline is not 0. Specify the pattern of the composite header line. If <auto> is selected, Origin will scan for recognized delimiters and will parse the line accordingly.

FileStruct

The FileStruct branch of the Options tree specifies the structure of the imported file.

Syntax: Options.FileStruct.Treenode:= <value>

Example:

Options.FileStruct.DataStruct:=1
Options.FileStruct.Delimiter:=2
Treenode Label Type Default Description
DataStruct Data Structure int 1 Specify the data structure of the file.

Options include:

  • 0: Fixed column widths
    Select this if data columns have fixed text width.
  • 1: Delimited - Single Character
    Select this if data columns are separated by a delimiter.
  • 2: Delimited - Multiple Characters
    Select this if data columns are separated by multiple characters.
Delimiter Delimiter int 0 Specify a delimiter. Available only when DataStruct = 1.

Options include:

  • 0: Unknown
    Data columns are separated by an auto-determined delimiter.
  • 1: Comma(,)
    Data columns are delimited by a comma.
  • 2: Tab
    Data columns are delimited by a tab.
  • 3: Tab/Space
    Data columns are delimited by single or multiple Tab(spaces).
  • 4: Semicolon(;)
    Data columns are delimited by a semicolon.
  • 5: Other
    Data columns are delimited by other delimiters.
  • 7: Space
    Data columns are delimited by space.
OtherDelimiter Other Delimiters string Specify a delimiter. Use when Data Structure = Delimited - Single Character and Delimiter = Other.
CombineDelimiters Treat Consecutive Delimiters as One int 0 You can assign multiple characters to Other Delimiters and treat as one delimiter (1); otherwise, two or more characters will be interpreted as a list of possible delimiters and the occurrence of any single character or combination of characters, will be treated as a single delimiter (0).
  • 0: Do not treat as one.
  • 1: Treat as one.
MultipleDelimiters Multiple Characters string Specify multiple characters. This is only available when Data Structure is Delimited - Multiple Characters. A matched sequence is treated as a single delimiter.
ColWidths Column Widths (e.g. 6, 3, 3, 8) int This is only available when Data Structure is set to Fixed column widths. Please note that you can specify varying column widths for each column by separating them with a comma (e.g. 6,3,3,8 for four columns with widths of 6,3,3, and 8 characters).
NumSep Numeric Separators int -2 The <auto> = -2 default uses the Preference: Options > Numeric Format > Separators for ASCII Import setting from the Origin GUI (normally, determined by your Windows regional settings). Other options are for specifying alternate numeric separators:
  • -2: <auto>
  • 1: 1,000.00
  • 2: 1.000,00
  • 3: 1 000,00
  • 4: 1'000.00
DateFormat Custom Date Format double <none> Specify the date format to be imported. If the specified date format matches the appearance of the date data in imported file, the data column format will be set as Date in the Column Properties dialog. For more details on custom date format string, please see the Custom Date Format page.

Origin provides over 20 options. Some popular choices:

  • dd'/'MM'/'yyyy
  • yyyy'-'MM'-'dd
  • yyyy'-'MM'-'dd HH':'mm':'ss
  • yyyyMMdd
TimeFormat Custom Time Format double <none> Specify the time format to be imported. If the specified time format matches the appearance of the time data in imported file, the time column format will be set as Time in the Column Properties dialog. For more details on custom time format string, please see the Custom Time Format page.

Origin provides over 15 options. Some popular choices:

  • HH':'mm
  • HH':'mm':'ss
TransposeData Transpose Data int 0

Specify whether to transpose the data during import.

Cols

The Cols branch of the Options tree specifies the properties of the columns of the imported file.

Syntax: Options.Cols.Treenode:= <value>

Example1

Options.Cols.AutoColTypes:=2
Options.Cols.ColDesignations:=X(YEN)
Treenode Label Type Default Description
NumCols Number of Columns int 0 Specify the number of columns.
AutoColTypes Auto determine column types int 2 Select this check box to let Origin automatically design the column types .
MinTestLns Min Number of Consistent Lines to Determine Data Structure int 4 Enter a numeric number N in the text box. When N lines are found to have the same structure, this structure will be used as the data structure for the whole file. This is only available when Auto-determine column types is checked.
MaxTestLns Max Number of Consistent Lines to Determine Data Structure int 50 Enter a number greater than the number of header rows but less than the number of lines in the file.
ColDesignations Column Designations string Specify the plot designations. Refer to this help page for more details of column designation syntax (including how to repeat designations). The specified column designation will be applied to all sheets automatically.

Names

The Names branch of the Options tree specifies how to name the worksheet and workbook.

Syntax: Options.Names.Treenode:= <value>

Example:

Options.Names.FNameToSht:=1
Options.Names.FNameToShtFrom:=1
Options.Names.FNameToShtTo:=4
Treenode Label Type Default Description
AutoNames Auto Rename Using File Name int 0 If this is enabled, Origin will use the default settings to rename the worksheet and workbook, which are:
  • Use the whole file name (not including the file extension) as the worksheet name.
  • Use the whole file name (including the file extension) as the workbook name if the current workbook is empty or the import mode is Replace Existing Data.
FNameToSht Rename Sheet with (Partial) Filename int 1 Enable this to use part of the file name as the worksheet name.
FNameToShtFrom Trim Filename From int 1 Specify the start of the name.
FNameToShtTo Trim Filename To int 0 Specify the end of the name.
FNameToBk Rename Book with (Partial) Filename int 1 Enable this to use part of the file name as the workbook name.
FNameToBkFrom Trim Filename From int 1 Specify the start of the name.
FNameToBkTo Trim Filename To int 0 Specify the end of the name.
FNameToBkLnOnly Rename Long Name for Book only int 0 Enable this to change the long name for the workbook only.
FPathToBk Include File Path when Renaming Book int 0 Specify whether the file path should be included in the workbook name.
FNameToBkComm Append Filename to Workbook Comment int 1 Specify whether the file name should be appended to the workbook comment.
FNameToWksComm Append Filename to Worksheet Comment int 0 Specify whether the file name should be appended to the worksheet comment.
FNameToColComm Append Filename to Column Comment int 0 Specify whether the file name should be appended to the column comment.
FNameToUDL Add Filename User Parameters Row int 0 Specify whether to put the file name to user parameter row SourceFile.
FPathToComm Include File Path when Appending Filename int 0 When this is enabled, the import file path is included to the file name (and the file extension is also included).
Notes:

Starting from Origin 8.6, the minus (-) value is supported in FNameToBkFrom and FNameToBkTo for counting to the end of a name from the last character of the file name. It can be used to trim the file extension when you rename a workbook. For example, if you want to import an ASCII file named sample.dat, you can specify settings to trim the extension ".dat" when renaming the workbook:

Options.Names.FNameToBkFrom:=1
Options.Names.FNameToBkTo:=-4

Partials

The Partials branch of the Options tree specifies how to partially import the file.

Syntax: Options.Partials.Treenode:= <value>

Example:

Options.PartImp.Partial:=1
Options.PartImp.FirstCol:=1
Options.PartImp.FirstCol:=3
Treenode Label Type Default Description
Partial Partial Import int 1 Specify whether to apply partial import to all files. 1 means apply partial import settings to all files and 2 means apply partial import settings to all files except 1st file.
partial_cols Partial Columns treenode <unassigned> Specify how to partial import file by column. See below table for detailed treenode options.
partial_rows Partial Rows treenode <unassigned> Specify how to partial import file by row. See below table for detailed treenode options.

The Partial_cols sub-branch of the partials tree specifies how to partially import by column.

Syntax: Options.Partials.partial_cols.Treenode:= <value>

Treenode Label Type Default Description
FirstCol From int 1 Specify the beginning column for a partial import.
LastCol To int 0 Specify the end column for a partial import.
ColRanges Custom string <optional> Specify the customized pattern to partial import columns.
ReadCols Read int 1 This works with SkipCols. It is only available when SkipCols is larger than 0.

Note that when a number j is specified for ReadCols and a number k for SkipCols, j columns are imported while k columns are skipped for every j+k columns.

SkipCols Skip int 0 This works with ReadCols.

The Partial_rows sub-branch of the partials tree specifies how to partially import by row.

Syntax: Options.Partials.partial_rows.Treenode:= <value>

Treenode Label Type Default Description
FirstRow From int 1 Specify the start row for a partial import.
LastRow To int 0 Specify the end row for a partial import.
RowRanges Custom string <optional> Specify the customized pattern to partial import rows.
ReadRows Read int 1 This works with SkipRows . It is only available when SkipRows is larger than 0.

Note that when a number j is specified for ReadRows and a number k for SkipRows, j rows are imported while k rows are skipped for every j+k rows.

SkipRows Skip int 0 This works with ReadRows.

Miscs

The Miscs branch of the Options tree specifies miscellaneous things for importing the file.

Syntax: Options.Miscs.Treenode:= <value>

Example: Options.Miscs.NonNum:=0

Treenode Label Type Default Description
Qualifier Text Qualifier int 0 Specify the text qualifier.

Options include:

  • 0:None
    Do not use the text qualifier.
  • 1:"
    Use " as the text qualifier.
  • 2:'
    Use ' as the text qualifier.
RemoveQuotes Remove Text Qualifier from Quoted Data int 1 Specify whether to remove the text qualifier from quoted data. This is available when a text qualifier is specified.
LeadingZeros Remove Leading Zeros from Numbers int 1 Specify whether to remove leading zeros from numbers.
NonNum When Non-numeric is Found in Numeric Field int 1 Specify how to import data when non-numeric data is found in a numeric field.

Options include:

  • 0:Terminate Import
    Terminate the importing process.
  • 1:Read as Text
    Import the non-numeric data as text.
  • 2:Start New Worksheet
    Start a new worksheet to import the non-numeric data.
  • 3:Start New Column
    Start a new column to import the non-numeric data.
  • 4:Start New hidden Workbook
    Start a new hidden workbook to import the non-numeric data.
  • 5:Skip
    When non-numeric data are encountered in a numeric field, skip over it.
AllowAllText Allow Import All Text Data int 1 Specify whether to allow importing all text data.
SaveFileInfo Save File Info. in Workbook int 1 Specify whether to save the information of the imported file in a workbook.

Scripts

The Scripts branch of the Options tree specifies the LabTalk scripts to run after file(s) being imported.

Syntax: options.scripts.Treenode:= <string>

Example:
//Plot second column for each imported file  :
options.scripts.ScriptAfterEachImport:="plotxy 2;";

//When all files being imported, loop over all worksheets in all workbooks and delete first 500 rows from column 1 to column 4.
options.scripts.ScriptAfterAllImport:=" doc -ef W { doc -e LW { range aa =1[1]:4[500]; del aa;}}";


Treenode Label Type Default Description
ScriptAfterEachImport Script after Each File Imported string "?" Specify LabTalk scripts that will be executed after each imported file.
ScriptAfterAllImport Script after All Files Imported string "?" Specify LabTalk scripts that will be executed only after all files being imported.