1.2 AutoLog

Highlights

- a log-like, space-delimited input file
- input format customization
- process auto run, when the input file changes

location:  InstallDir/Samples/TextConverter/Manual Mode/1 Well formed input/

project file:  InstallDir/Samples/TextConverter/Manual Mode/1 Well formed input/1.2 AutoLog.ConverterX


1. Launch TextConverter or clear the project by pressing the New button () in the tool bar or by selecting "New" from "File" menu

2. Open the "1.2 AutoLof.txt" input text file.  (See loading an input file for details.)

Because only one field is visible in the input dictionary list, it is evident from the current field delimiter (comma) is not an appropriate field delimiter for this text file. Let's set the field delimiter option to space " " and immediately we see eight fields.

3. The values for Field_1 and Field_2 do not look correct in the output preview - they should be date fields. Change the data types of Field_1 and Field_2 to Date type in the output dictionary list.  Now we can set the input formats for those two fields using the input dictionary editor. Set Field_1's input format to [YYYY-MM-DD and Field_2's  to hh:mm:ss]. Now the output preview shows the correct results for the first two fields. (See date formats to learn more.)

4. Process automation. Scheduler is a very convenient tool for running data conversion projects on a regular basis. Let's assume that we need this project to run only if the input file was updated since the last run.

a) Connect the project to the scheduler tool (select the "Task Scheduler" item from the "File" menu) and set it to be started daily.

b) Now switch to the script editor and create the OnStartProcess context method by selecting the "OnStartProcess" item from the script editor's context menu. The following VB Script sample illustrates how to check if the input file was changed since the last run. OldDate is a target variable which holds the previous run date and is initially empty.

'----------------- OnStartProcess -----------------
Function OnStartProcess
If this.IsRunning() Then
   Dim fso, file, ok
   Set fso = CreateObject("Scripting.FileSystemObject")
   Set file = fso.GetFile( this.GetInputFile() )
   If Not OldDate.IsEmpty() And file.DateLastModified = OldDate.value Then
       this.Cancel
    End If
    OldDate.value = file.DateLastModified
End If
End Function

See scripting for details on script objects and methods.


Go to 1.3 Positional for more training.


Related Sections

TextConverter's Concept

Setting up a Conversion: Step-by-Step

Samples and Walkthroughs

User Interface

Scripting

 

Comments