tFileCompare
Compares two files and provides comparison data based on a read-only
schema.
tFileCompare Standard properties
These properties are used to configure tFileCompare running in the Standard Job framework.
The Standard
tFileCompare component belongs to the File family.
The component in this framework is available in all Talend
products.
Basic settings
Schema and Edit |
A schema is a row description, it defines the number of fields to be processed and The schema of this component is read-only. |
File to compare |
Filepath to the file to be checked. Warning: Use absolute path (instead of relative path) for
this field to avoid possible errors. |
Reference file |
Filepath to the file, the comparison is based on. Warning: Use absolute path (instead of relative path) for
this field to avoid possible errors. |
If differences are detected, display and |
Type in a message to be displayed in the Run console based on the result of the |
Print to console |
Select this check box to display the message. |
Advanced settings
Encoding |
Select the encoding from the list or select Custom and define it manually. This field is |
tStatCatcher Statistics |
Select this check box to gather the Job processing metadata at a |
Global Variables
Global Variables |
DIFFERENCE: the result of the comparison. This is a Flow
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 but it is |
Connections |
Outgoing links (from this component to another): Row: Main.
Trigger: On Subjob Ok; On Subjob Incoming links (from one component to this one):
Row: Main; Reject;
Trigger: Run if; On Subjob Ok; On For further information regarding connections, see |
Comparing unzipped files
This scenario describes a Job unarchiving a file and comparing it to a reference file
to make sure it did not change. The output of the comparison is stored into a delimited
file and a message displays in the console.
Procedure
-
Drag and drop the following components: tFileUnarchive, tFileCompare,
and tFileOutputDelimited. - Link the tFileUnarchive to the tFileCompare with Iterate connection.
-
Connect the tFileCompare to the output
component, using a Main row link. -
In the tFileUnarchive component Basic settings, fill in the path to the archive to
unzip. -
In the Extraction Directory field, fill in
the destination folder for the unarchived file. -
In the tFileCompare
Basic settings, set the File to
compare. Press Ctrl+Space bar to display the
list of global variables. Select
$_globals{tFileUnarchive_1}{CURRENT_FILEPATH} or
“((String)globalMap.get(“tFileUnarchive_1_CURRENT_FILEPATH”))”
according to the language you work with, to fetch the file path from the
tFileUnarchive component. -
And set the Reference file to base the
comparison on it. -
In the messages fields, set the messages you want to see if the files differ
or if the files are identical, for example: “[job ” + JobName + “]
Files differ”. -
Select the Print to Console check box, for
the message defined to display at the end of the execution. -
The schema is read-only and contains standard information data. Click
Edit schema to have a look to it. -
Then set the output component as usual with semi-colon as data
separators. -
Save your Job and press F6 to run it.
The message set is displayed to the console and the output shows the schema
information data.