File: Batch Processing
Perform Batch Processing with Analysis Template
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;
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 |
---|---|---|---|---|
Batch Processing Mode | batch |
Input int |
|
Specify the batch processing mode. Option list:
|
Analysis Template | name |
Input string |
|
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 |
|
Specify the Word related options in the dialog. See more details in the Word/PDF page. |
Data Source | data |
Input int |
|
Specify what kind of data source will be used.
Option list:
|
Use Import Setting in Workbook | last |
Input int |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
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 |
|
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 |
|
This can only be accessed from LabTalk scripts. Specify the method to import the data files. Options include:
| |
theme |
Input string |
|
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 |
|
This is available only when Method is selected as ImportWizard. Specify a filter to import data files. | |
script |
Input string |
|
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 |
|
Specify the source data worksheet in the analysis template. |
Result Sheet | append |
Input string |
|
Specify analysis result sheet in the analysis template. |
Output Sheet | ow |
Output Worksheet |
|
Specify the worksheet to which results from the Result Sheet will be appended.
See syntax here. |
Delete Intermediate Analysis Outputs | remove |
Input int |
|
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 |
|
Specify the beginning row in Output sheet to append results. |
Clear Output Sheet on Start | clear |
Input int |
|
Clear the Output Sheet when starting the process. |
Append Label Rows | label |
Input int |
|
Specify whether to append label rows of the first Result Sheet to Output Sheet. |
Append by | mode |
Input int |
|
Specify the way to append the data to Output Sheet.
Option list:
|
Script Before Each Process | beforescript |
Input string |
|
Scripts in this edit box will be executed before each process. Note that: fname$ refers to the i-th file
|
Script after Each Process | loopscript |
Input string |
|
Scripts in this edit box will be executed after each process. Note that: _i refers to the index of i-th file/dataset
|
Script at the End | endscript |
Input string |
|
Scripts in this edit box will be executed at the end of the whole process. |
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.
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";
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;