tFileExist
tFileExist Standard properties
These properties are used to configure tFileExist running in the Standard Job framework.
The Standard
tFileExist component belongs to the File family.
The component in this framework is available in all Talend
products.
Basic settings
File name/Stream |
Path to the file you want to check if it exists or not. Warning: Use absolute path (instead of relative path) for
this field to avoid possible errors. |
Advanced settings
tStatCatcher Statistics |
Select this check box to gather the Job processing metadata at a |
Global Variables
Global Variables |
EXISTS: the result of whether a specified file exists.
FILENAME: the name of the file processed. This is an
ERROR_MESSAGE: the error message generated by the A Flow variable functions during the execution of a component while an After variable To fill up a field or expression with a variable, press Ctrl + For further information about variables, see |
Usage
Usage rule |
This component can be used as standalone component. |
Connections |
Outgoing links (from this component to another):
Trigger: On Subjob Ok; On Subjob Incoming links (from one component to this one): Row: Iterate.
Trigger: Run if; On Subjob Ok; On For further information regarding connections, see |
Checking for the presence of a file and creating it if it does not
exist
This scenario describes a simple Job that: checks if a given file exists, displays a
graphical message to confirm that the file does not exist, reads the input data in
another given file and writes it in an output delimited file.
A dialog box appears to confirm that the file does not exists.
Click OK to close the dialog box and continue the Job
execution process. The missing file, file1 in this scenario, got written in a delimited
file in the defined place.
Dropping and linking the components
- Drop the following components from the Palette onto the design workspace: tFileExist, tFileInputDelimited, tFileOutputDelimited, and tMsgBox.
-
Connect tFileExist to tFileInputDelimited using an OnSubjobOk and to tMsgBox using
a Run If link. -
Connect tFileInputDelimited to tFileOutputDelimite using a Row
Main link.
Configuring the components
-
In the design workspace, select tFileExist
and click the Component tab to define its basic
settings. -
In the File name field, enter the file path
or browse to the file you want to check if it exists or not. -
In the design workspace, select tFileInputDelimited and click the Component tab to define its basic settings.
-
Browse to the input file you want to read to fill out the File Name field.
Warning:
If the path of the file contains some accented characters, you
will get an error message when executing your Job. - Set the row and field separators in their corresponding fields.
-
Set the header, footer and number of processed rows as needed. In this
scenario, there is one header in our table. -
Set Schema to Built-in
and click the Edit schema button to
define the data to pass on to the tFileOutputDelimited component. Define the data present in the
file to read, file2 in this scenario.For more information about schema types, see
Talend Studio
User
Guide.The schema in file2 consists of five columns: Num, Ref, Price,
Quant, and tax. - In the design workspace, select the tFileOutputDelimited component.
-
Click the Component tab to define the basic
settings of tFileOutputDelimited. - Set property type to Built-in.
-
In the File name field, press Ctrl+Space to access the variable list and select the
global variable FILENAME. - Set the row and field separators in their corresponding fields.
-
Select the Include Header check box as file2
in this scenario includes a header. -
Set Schema to Built-in and click Sync columns to synchronize the output file schema (file1) with
the input file schema (file2). -
In the design workspace, select the tMsgBox
component. -
Click the Component tab to define the basic
settings of tMsgBox. -
Click the If link to display its properties
in the Basic settings view. -
In the Condition panel, press Ctrl+Space to access the variable list and select the
global variable EXISTS. Type an exclamation mark before the variable to negate
the meaning of the variable.
Saving and executing the Job
- Press Ctrl+S to save your Job.
-
Press F6 or click the Run button in the Run tab to
execute it.