Capturing file information
Another useful Talend feature is the ability to capture information about a file for use within downstream processing, most probably to perform validation prior to processing.
Getting ready
Open the jo_cook_ch08_0110_fileInformation
job.
How to do it...
The steps for capturing file information are as follows:
Drag a
tFileProperties
component from the right-hand panel. OpentFileProperties,
and set the file name tocontext.cookbookData+"/chapter8/chapter08_jo_0110_customerData.txt"
.Drag
tFlowToIterate
to the canvas, and link the row fromtFileProperties
to it. Name the flowproperties
.Drag
tFileRowCount
to the canvas and set the filename to match thetFileProperties
component.Add
onSubjobOk
fromtFileProperties
totFileRowCount,
and then totFixedFlowInput,
so that your job looks like the one shown as follows:Open
tFixedFlowInput
.Add
((Long)globalMap.get("properties.size"))
to the field fileSize.Add
((Integer)globalMap.get("tFileRowCount_1_COUNT"))
to the field numberOfRows...