August 17, 2023

tCreateTemporaryFile – Docs for ESB 5.x

tCreateTemporaryFile

tCreateTemporaryFile_icon32_white.png

tCreateTemporaryFile properties

Component family

File/Management

 

Function

tCreateTemporaryFile creates and
manages temporary files.

Purpose

tCreateTemporaryFile helps to
create a temporary file and puts it in a defined directory. This
component allows you to either keep the temporary file or delete it
after Job execution.

Basic settings

Remove file when execution is over

Select this check box to delete the temporary file after Job
execution.

 

Use default temporary system directory

Select this check box to create the file in the system’s default
temporary directory.

 

Directory

Select this check box to create the temporary file .

 

Template

Enter a name to the temporary file respecting the template.

 

Suffix

Enter the filename extension to indicate the file format you want
to give to the temporary file.

Usage

tCreateTemporaryFile provides the
possibility to manage temporary files so that the memory can be
freed for other ends and thus optimizes system performance.

Global Variables

FILEPATH: the path where the file was created. This is an
After variable and it returns a string.

ERROR_MESSAGE: the error message generated by the
component when an error occurs. This is an After variable and it returns a string. This
variable functions only if the Die on error check box is
cleared, if the component has this check box.

A Flow variable functions during the execution of a component while an After variable
functions after the execution of the component.

To fill up a field or expression with a variable, press Ctrl +
Space
to access the variable list and choose the variable to use from it.

For further information about variables, see Talend Studio
User Guide.

Connections

Outgoing links (from this component to another):

Trigger: On Subjob Ok; On Subjob
Error; Run if; On Component Ok; On Component Error.

Incoming links (from one component to this one):

Row: Iterate.

Trigger: Run if; On Subjob Ok; On
Subjob Error; On component Ok; On Component Error; Synchronize;
Parallelize.

For further information regarding connections, see
Talend Studio User
Guide
.

Log4j

The activity of this component can be logged using the log4j feature. For more information on this feature, see Talend Studio User
Guide
.

For more information on the log4j logging levels, see the Apache documentation at http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/Level.html.

Limitation

n/a

Scenario: Creating a temporary file and writing data in it

The following scenario describes a simple Job that creates an empty temporary file in
a defined directory, writes data in it and deletes it after Job execution.

Dropping and linking components

  1. Drop the following components from the Palette onto the design workspace: tCreate
    temporaryFile
    , tRowGenerator,
    tFileOutputDelimited, tFileInputDelimited and tLogRow.

  2. Connect tCreateTemporaryFile to tRowGenerator using a SubjobOk link.

  3. Connect tRowGenerator to tFileOutputDelimited using a Row Main link.

  4. Connect tRowGenerator to tFileInputDelimited using a SubjobOk link.

  5. Connect tFileInputDelimited to tLogRow using a Row
    Main
    link.

    Use_Case_tCreateTemporaryFile.png

Configuring the components

  1. In the design workspace, select tCreateTemporaryFile.

  2. Click the Component tab to define the basic
    settings for tCreateTemporaryFile.

    Use_Case_tCreateTemporaryFile1.png
  3. Select the Remove file when execution is over
    check box to delete the created temporary file when Job execution is
    over.

  4. Click the three-dot button next to the Directory field to browse to the directory where temporary files
    will be stored, or enter the path manually.

  5. In the Template field, enter a name for the
    temporary file respecting the template format.

  6. In the Suffix field, enter a filename
    extension to indicate the file format you want to give to the temporary
    file.

  7. In the design workspace, select tRowGenerator
    and click the Component tab to define its basic
    settings.

    Use_Case_tCreateTemporaryFile2.png
  8. Set the Schema to Built-In.

  9. Click the Edit schema three-dot button to
    define the data to pass on to the tFileOutputDelimited component, one column in this scenario,
    value.

    Click OK to close the dialog box.

    Use_Case_tCreateTemporaryFile3.png
  10. Click the RowGenerator Editor three-dot
    button to open the editor dialog box.

    Use_Case_tCreateTemporaryFile4.png
  11. In the Number of Rows for Rowgenerator field,
    enter 5 to generate five rows and click
    Ok to close the dialog box.

  12. In the design workspace, select tFileOutputDelimited and click the Component tab to define its basic settings.

    Use_Case_tCreateTemporaryFile5.png
  13. Set Property Type to Built-In.

  14. Click in the File Name field and use the
    Ctrl+Space bar combination to access the
    variable completion list. To output data in the created temporary file, select
    tCreateTemporaryFile_1.FILEPATH on the global variable
    list.

  15. Set the row and field separators in their corresponding fields as
    needed.

  16. Set Schema to Built-In and click Sync columns
    to synchronize input and output columns. Note that the row connection feeds
    automatically the output schema.

    For more information about schema types, see Talend Studio
    User Guide.

  17. In the design workspace, select the tFileInputDelimited component.

  18. Click the Component tab to define the basic
    settings of tFileInputDelimited.

    Use_Case_tCreateTemporaryFile6.png
  19. Click in the File Name field and use the
    Ctrl+Space bar combination to access the
    variable completion list. To read data in the created temporary file, select
    tCreateTemporaryFile_1.FILEPATH on the global variable
    list.

  20. Set the row and field separators in their corresponding fields as
    needed.

  21. Set Schema to Built in
    and click Edit schema to define the
    data to pass on to the tLogRow component. The
    schema consists of one column here, value.

Saving and executing the Job

  1. Press Ctrl+S to save the Job.

  2. Press F6 to execute the Job or click the
    Run button of the Run tab.

    Use_Case_tCreateTemporaryFile7.png

The temporary file is created in the defined directory during Job execution and the
five generated rows are written in it. The temporary file is deleted when Job execution
is over.


Document get from Talend https://help.talend.com
Thank you for watching.
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x