2.15.3.7 Details of TreeNodes in Import CSV


options

The Options tree specifies all import options for the impCSV X-Function.

Syntax: Options.Treenode:=<value>

Example: Options.decimal:=1

Treenode Label Type Default Description
decimal Delimiter int 0 Specify a delimiter. Options include:
  • 0: Comma
    Data columns are delimited by comma.
  • 1: Semicolon
    Data columns are delimited by semicolon.
  • 2: Auto
    Data columns are delimited by auto-determined delimiter.
FirstMode 1st File Import Mode int 0 Specify the import mode for the 1st file. Options include:
  • 0: Replace Existing Data
    The data that exists in the target window will be wiped out. And the new data will be imported into it.
  • 3: Start New Books
    Create a new book for the file that will be imported.
  • 4: Start New Sheets
    Create a new sheet for the file that will be imported.
  • 1: Start New Columns
    Add new columns to the target worksheet and import the data into the new columns.
  • 2: Start New Rows
    Add new rows to the target worksheet and import the data into the new rows.
Mode Multi-File (except 1st) Import Mode int 4 Specify the import mode from the list for the files other than 1st. Options include:
  • 3: Start New Books
    Create a new book for the file that will be imported.
  • 4: Start New Sheets
    Create a new sheet for the file that will be imported.
  • 1: Start New Columns
    Add new columns to the target worksheet and import the data into the new columns.
  • 2: Start New Rows
    Add new rows to the target worksheet and import the data into the new rows.
WinTemplate Template Name String <default> This option is available when the Import Mode is Start New Sheets or Start New Books. Specify the template to import the file to a new book or new sheet. A special template <clone> can be used to specify current workbook or matrix book as template to import files.
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.
nAutoSize Auto Resize Cells int 1 Resize the cells of the worksheet automatically.

Options include:

  • 0: No
    Do not resize the cells.
  • 1: Width
    Just reset the width of the cells automatically.
  • 2: Height
    Just reset the height of the cells automatically.
  • 3: Width and Height
    Reset both the width and height of the cells automatically.
DataWriteProtection Data Protection int 0 Specify the imported data whether allow to be modified.

Options include:

  • 0: No
    The imported data can be modified.
  • 1: Read Only
    The imported data is not allowed to be edited and sorted
  • 2: Allow Sorting Only
    The imported data is not allowed to be edited, but can be sorted.
DateFormat Custom Data Format double Select a date format from the drop-down list, or type in a custom date format string. For more details, please see the [ Custom Date Format] page.

Options include:

  • <none>
  • yyyy'-'MM'-'dd HH':'mm':'ss
  • yyyy'-'MM'-'dd HH':'mm':'ss'.'###
  • yyyy'-'MM'-'dd hh':'mm':'ss tt
  • dd'/'MM'/'yyyy
  • dd'-'MM'-'yy
  • MM'/'dd'/'yyyy
  • MM'-'dd'-'yy
  • yy'/'MM'/'dd
  • yy'.'MM'.'dd
  • dd'.'MM'.'yy
  • yyyyMMdd
  • dd'-'MMM'-'yy
KeepDestColFmt Keep target column format int 0 Specify whether to keep target column format.

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 it is checked, Origin will use the default settings to rename the worksheet and workbook name, which is:
  • Use the whole filename (not including the file extension) as worksheet name.
  • Use the whole filename (including the file extension) as workbook name if current workbook is empty or the import mode is Replace Existing Data.
FNameToSht Rename Sheet with (Partial) Filename int 1 Check this to use part of the filename as 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 Check this to use part of the filename as 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 Check this to rename the long name for workbook only.
FPathToBk Include File Path when Renaming Book int 0 Specify if the file path should be included for the workbook name.
FNameToBkComm Append Filename to Workbook Comment int 1 Specify if the filename should be appended to the workbook comment.
FNameToWksComm Appen Filename to Worksheet Comment int 0 Specify if the filename should be appended to the worksheet comment.
FNameToColComm Append Filename to Column Comment int 0 Specify if the filename 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 checked, the import file path is appended to the workbook's comment and/or Comments row.
Notes:

From Origin 8.6, minus value is supported in FNameToBkFrom and FNameToBkTo to count the end of the name from the last character of the file name. It can be used to trim the file extension when you rename workbook. For example, if you want to import a csv file named sample.csv, you can specify the setting as below to trim the extension ".csv" when renaming the workbook name:

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

HeaderLines

The HeaderLines branch of the Options tree specifies the header information of the data file.

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

Example: Options.HeaderLines.SNames:= 1

Treenode Label Type Default Description
MainHdrLns Number of Main Header Lines(exclude subheader lines) int 0 Some files -- particularly those generated by lab instrumentation -- will have, at the top of the file, some header information that typically identifies the instrument, the operator, the date, the sample number, etc. These are the main header lines. It is used to specify where main header lines are.
AutoSubHeaderLines Auto Determine Subheader Lines int 1 Select this check box to have Origin automatically determine the number of 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.
SubHeaderLines Number of Subheader Lines int 0 It is used to specify the number of subheader lines of file.
ShortNames Short Names int 0 Specify which line of the file header to use for the short names of the worksheet row heading. Note that the number starts from the beginning of subheader lines rather than that of the whole header lines. Same for the settings below.

Note that from Origin 2017 column Short Name is restricted to alphabetical order and it cannot be edited by default. So Short Name option is hidden from GUI. If you want to rename column Short Names, you will need to go to the target workbook, uncheck Spreadsheet Cell Notation checkbox in the Properties tab of Window Properties dialog to enable editing column Short Name.

LongNames Long Names int 0 Specify the line for long names.
Units Units int 0 Specify the line for units.
CommentsFrom Comments From int 0 Specify the line which the comments start from.
CommentsTo Comments to int 0 Specify the line which the comments end with.
ParamsFrom System Parameters From int 0 Specify the line which the system parameters start from.
ParamsTo System Parameters To int 0 Specify the line which the system parameters end with.
UserParamsFrom User Parameters From int 0 Specify the line which the user parameters start from.
UserParamsTo User Parameters To int 0 Specify the line which the user parameters end with.

partial

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

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

Example:

Options.partial.Partial:=1
Options.partial.FirstCol:=1
Options.partial.LastCol:=3
Treenode Label Type Default Description
Partial Partial Import int 0 Set it to 0 to disable partial import; set it to 1 or 2 to enable partial import. 1 means apply partial import settings to all files and 2 means apply partial import settings to all files except 1st file.
FirstCol Start Column int 1 This is only available when Partial is enabled(set to 1 or 2). Specify the begin column for partial import.
ReadCols Read Columns int 1 This is only available when Partial is enabled(set to 1 or 2) and "Skip columns" is larger than 0. Specify how many columns to read before skipping column(s) for partial import.

Note that When you specify a number l for Read Columns and a number k for Skip Columns, l columns are imported while k columns are skipped for every l+k columns.

SkipCols Skip Columns int 0 This is only available when Partial is enabled(set to 1 or 2). Specify how many columns to skip after each reading for partial import.
LastCol To Column int 0 This is only available when Partial is enabled(set to 1 or 2). Specify the end column for partial import.
FirstSample From Row int 1 Specify the start row of the file to be imported. This is only available when Partial is enabled(set to 1 or 2).
ReadSamples Read Rows int 0 This works with Skip Rows. It is only available when Partial is enabled(set to 1 or 2) and Skip Rows is larger than zero.

Note that When you specify a number l for Read Rows and a number k for Skip Rows, l rows are imported while k rows are skipped for every l+k rows.

SkipSamples Skip Rows int 1 Some rows can be skipped according to the setting. This is only available when Partial is enabled(set to 1 or 2).
LastSample To Row int 0 Specify the end row of the file to be imported. This is only available when Partial is enabled(set to 1 or 2).

Script

The Script 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.