2.7.1 batchProcess


Menu Information

File: Batch Processing

Brief Information

Perform Batch Processing with Analysis Template

Command Line Usage

1. Repeatedly Import into Active Analysis Template Window

string fname$, path$="C:\Data\"; 
findfiles fname:=fname$ ext:="*.dat"; // findFiles will default to get from path$
batchProcess batch:=active fill:="Linear Fit"  method:="impAsc" theme:="batchImporting" append:="FitLinearCurve1";

2. Load Analysis Template

string fname$, path$="C:\Data\"; 
findfiles fname:=fname$ ext:="*.dat"; 
batchProcess batch:=template fill:="Linear Fit" append:="FitLinearCurve1" name:="C:\Data\LinearFit.ogw" method:="impAsc" theme:="batchImporting";

3. Add bookmarks from a Word template to Analysis template and output batch processed results to a word file

string fname$, path$="E:\Test\"; 
findfiles fname:=fname$ ext:="*.dat"; 
batchProcess name:="E:\Test\Sensor Analysis.ogw" word.template:="E:\Test\Sensor Analysis Report.dotx" word.export:=1 id:="File Name" fill:=Data append:=Result;

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
Batch Processing Mode batch

Input

int

1

Specify the batch processing mode.

Option list:

  • active:Repeatedly Import into Active Analysis Template Window
In this mode, Origin will repeatedly import data files to a preloaded analysis template and then send the results of each analysis process to the Output Sheet.
  • template:Load Analysis Template
In this mode, Origin will load the template for N times (N is the number of the data files which need to be processed.). Each time, it will perform analysis with the imported data file and then send the results to the Output Sheet.
Analysis Template name

Input

string

<unassigned>

This is available only when the Batch Processing Mode is set to Load Analysis Template. It can be used to specify the analysis template.

Word/PDF word

Input

Treenode

<unassigned>

Specify the Word related options in the dialog. See more details in the Word/PDF page.

Data Source data

Input

int

0
Specify what kind of data source will be used.

Option list:

  • import:Import Specified Files
    Data will be imported from files.
  • existingXY:Use Existing XY Datasets
    Use existing XY datasets in the project.
  • existingXYZ:Use Existing XYZ Datasets
    Use existing XYZ datasets in the project.
  • existingwks:Use Existing Worksheets
    Use existing worksheets in the project.
  • existingRange:Use Existing Ranges
    Use exissting ranges in the project.
  • folder:Import All Files from Folder
    Import all files from specified folder.
Use Import Setting in Workbook last

Input

int

1
Specify whether to use the last data importing settings. This is available only when Data Source is Import From Files.
File List fname

Input

string

fname$
Specify the data files which will be imported into the Data Sheet.
Folder path

Input

string

Available when Data Source is Import All Files from Folder. Specify the folder for the imported files.
File Extension ext

Input

string

*.*
Available when Data Source is Import All Files from Folder. Specify the extension for the imported files. It supports multiple extensions separated by semicolon.

For example: *.dat*; *.csv*

Input iy

Input

XYRange

<active>
This is available only when Use Existing XY Datasets has been selected for Data Source. It specifies the xy ranges for batch processing.
Input iz

Input

XYZRange

<active>
This is available only when Use Existing XYZ Datasets has been selected for Data Source. It specifies the xyz ranges for batch processing.
Fixed Range irngf

Input

Range

<optional>
This is available only when Use Existing Ranges has been selected for Data Source. It specifies the fixed ranges which will just be copied to the corresponding columns in the data sheet of template but do not take part in calculation during each processing loop.
Batch Range irngb

Input

Range

<unassigned>
This is available only when Use Existing Ranges has been selected for Data Source. It specifies the batch ranges which are the input data of the calculation during batch processing.
Worksheets iw

Input

Range

<unassigned>
This is available only when Use Existing Worksheets has been selected for Data Source. It specifies the worksheets for batch processing.
Dataset Identifier id

Input

string

None
Specify whether to add a column with Long Name of "Dataset" to the Output Sheet for identifying each analysis dataset. If None, such a column will not be added. Otherwise, when Data Source is Use Existing XY/XYZ Datasets, Dataset Identifier can be Range, Book Name, Sheet Name, Long Name, Units or Comments. When Data Source is Import From Files, File Name, Long Name, Units or Comments can be chosen. When Data Source is Use Existing Worksheets/Ranges, just Range, Book Name or Sheet Name can be chosen.
Designation desig

Input

string

<auto>
This is available only when column label row (Long Name, Units or Comments) is selected for Dataset Indentifier, or when Use Existing XY/XYZ Datasets is selected for Data Source and Range is selected for Dataset Identifier. The columns with the specified designation (X, Y or Z) are used as dataset identifier in the Output Sheet.
method

Input

string

ImportWizard
This can only be accessed from LabTalk scripts. Specify the method to import the data files. Options include:
  • ImportWizard
You can use Import Wizard to import the files. With this method, you need to specify a Filter to import the data files.
  • Script
You can write LabTalk scripts to import the data files.
  • All import X-Function, such as impASC, impCSV, impExcel etc.
You can specify any data importing X-Function (method:="impASC") to import data. With this method, you must specify a Theme.
theme

Input

string

<auto>
This is available only when Method is selected as an importing X-Function. Specify the theme file to import the data files.
filter

Input

string

<auto>
This is available only when Method is selected as ImportWizard. Specify a filter to import data files.
script

Input

string

<unassigned>
This is available only when Method is selected as Script. These scripts will be used to import the data files.
Data Sheet(s) fill

Input

string

<unassigned>
Specify the source data worksheet in the analysis template.
Result Sheet append

Input

string

ToAppend
Specify analysis result sheet in the analysis template.
Output Sheet ow

Output

Worksheet

[Summary]Results!
Specify the worksheet to which results from the Result Sheet will be appended.

See syntax here.

Delete Intermediate Analysis Outputs remove

Input

int

1
Specify whether to delete the intermediate analysis outputs after the process. Accessible only when Repeatedly Import into Active Analysis Template Window is selected for Batch Processing Mode.
Starting Row of Output Sheet number

Input

int

1
Specify the beginning row in Output sheet to append results.
Clear Output Sheet on Start clear

Input

int

1
Clear the Output Sheet when starting the process.
Append Label Rows label

Input

int

0
Specify whether to append label rows of the first Result Sheet to Output Sheet.
Append by mode

Input

int

0
Specify the way to append the data to Output Sheet.

Option list:

  • rows{0}:Rows
    Append the data by row.
  • cols{1}:Columns
    Append the data by column.
Script Before Each Process beforescript

Input

string

<unassigned>
Scripts in this edit box will be executed before each process.
Note that:

fname$ refers to the i-th file
_rx refers to the range of i-th x dataset
_ry refers to the range of i-th y dataset
_skip determines if i-th file/dataset will be skipped

Script after Each Process loopscript

Input

string

<unassigned>
Scripts in this edit box will be executed after each process.
Note that:

_i refers to the index of i-th file/dataset
_book$ refers to the i-th book name
Variable i and __BATCHBOOK$ defined in earlier version are replaced by _i and _book$, respectively.

Script at the End endscript

Input

string

<unassigned>
Scripts in this edit box will be executed at the end of the whole process.

Description

This X-Function performs batch processing and generates a summary report. You should first create an analysis template, and then reuse the template in this process. This function provides options for either repeatedly importing data into the current workspace's analysis template, or for loading a previously saved analysis template.

More details, please see Batch Processing.

Examples

Example 1

In this example, we will run a script to fit all files named step0*.dat:

// File path
string path$ = system.path.program$ + "Samples\Curve Fitting\";
string fname$;
// Find all files like step01.dat, step02.dat
// findFiles will default to get files from path$
findfiles fname:=fname$ ext:="step0*.dat";
// Specify the analysis template
string tp$ = path$ + "autofit.ogw";

Then you can go ahead to batch your data files

// Perform general batch process.
// File list is saved in fname$
batchprocess batch:=1 name:=tp$ method:="impAsc" fill:="Data" append:="Summary";

Example 2

This example will show you how to directly generate pdf report by an existing Word template.

// Assume you have an existing Word report template under D dirve
// Assume you have already created the bookmark sheet and done or the linking settings
string strWordTemplatePath$ = "D:\ReportTemplate.dotx";  
string strExportPath$ = "D:\";
batchprocess batch:=1 name:=tp$ method:="impAsc" fill:="Data" append:="Summary" Word.export:=2 Word.template:=strWordTemplatePath$ Word.Path:=strExportPath$ Word.overwrite:=1;