July 30, 2023

cFlatPack – Docs for ESB ESB 7.x

cFlatPack

Processes fixed width or delimited files or messages using the FlatPack
library

cFlatPack Standard properties

These properties are used to configure cFlatPack running in the Standard Job framework.

The Standard
cFlatPack component belongs to the Transformation family.

Basic settings

When using as a start component in a route:

 

PZMAP FileType

The PZMAP file is the Flatpack configuration file that is used to configure the
structure of the input file. For more information about the PZMAP
file configuration, see the website http://flatpack.sourceforge.net/documentation/index.html.

Select the PZMAP file type from Filename and Repository Resource.

Filename: The PZMAP file is stored in the local file
system.

Repository Resource: The PZMAP file is stored in the
Resources node of the Repository.

PZMAP Filename

This option appears when Filename is selected in the
PZMAP FileType list. Enter or
browse to the path to the PZMAP file.

PZMAP Repository Resource

This option appears when Repository
Resource
is selected in the PZMAP FileType list. Click […] and select the PZMAP file under the Resources node in the dialog box.

Fixed Positional file

Select this option if the file is a fixed format file.

Delimited file

Select this option if the file is delimited.

Text Qualifier: Specify the text
qualifier for delimited files. The default value is
".

Text Delimiter: Specify the
character delimiter for delimited files. The default value is
,.

Split Rows

Select this check box to process each row one by one.

Ignore First Record

Select this check box to ignore the first line for delimited files
(for the column headers). This option is only available if the
Delimited file option is
selected.

Allow Short Lines

Select this check box to allow lines shorter than expected by the PZMAP file.

Ignore Extra Columns

Select this check box to allow lines longer than expected by the PZMAP file and ignore
the extra characters.

When using as a middle or end component in a Route:

 

Use Exist cFlatPack

Click […] and select the cFlatPack component to be used as the file parser in
the dialog box.

Usage

Usage rule

cFlatPack can be a start, middle, or end component in
a Route.

Limitation

 n/a

Parsing delimited file using the cFlatPack component

This scenario applies only to Talend Open Studio for ESB, Talend Data Services Platform and Talend Data Fabric.

In this scenario, a cFile component reads a delimited file
from the local file system, which contains the customers information including id, first
name, surname, and order id, as shown below:

The file is parsed by the cFlatPack component, using
a predefined PZMAP XML file:

The customer information is then printed in the execution console by a cBean component.

For more information about the PZMAP file configuration, see the website http://flatpack.sourceforge.net/documentation/index.html.

Creating a Bean

In this section, a Java bean is created to print the id, first name, and surname
from the customer information with the corresponding column names into the execution
console.

  1. From the repository tree view, expand the Code node and right click the Beans node. In the contextual menu, select Create Bean.

    The New Bean wizard opens. In the Name field, type in a name for the bean, for
    example, ReadOrder. Click Finish to close the wizard. The bean is opened automatically
    in the design workspace.
    cFlatPack_1.png

  2. Enter the following code in the design workspace.

  3. Press Ctrl+S to save your bean.

For more information about creating and using Java Beans, see
Talend Studio User
Guide
.

Dropping and linking the components

cFlatPack_2.png

  1. From the Palette, drag and drop a
    cFile, two cFlatPack, a cBean, and a
    cLog component onto the design
    workspace.
  2. Link the components using the Row >
    Route connection as shown above.
  3. Label the components to better identify their roles in the Route.

Configuring the components and connections

  1. Double-click Delimited_file in the design workspace to
    display its Basic settings view in the
    Component tab.

    cFlatPack_3.png

  2. In the Path field, browse to or enter the file path
    where the flatpack file is located.

    In the FileName field, enter the name of
    the file to be processed.
  3. Double-click Flat_file_parser to display its Basic settings view in the Component tab.

    cFlatPack_4.png

  4. Click […] and in the Select a
    Node:
    wizard, select FlatPack_config to configure the structure of the input
    file.

    cFlatPack_5.png

  5. Double-click FlatPack_config to display its Basic settings view in the Component tab.

    cFlatPack_6.png

  6. In the PZMAP FileType list, select Filename to use the PZMAP XML file from the local file
    system to configure the structure of the input file. Then in the PZMAP Filename field, browse to path
    where the PZMAP XML file is located.

    Select the Allow Short Lines check box to
    allow lines shorter than expected by the PZMAP file.
    Keep the default settings of the other options.
  7. Double-click ReadOrder to display its Basic settings view in the Component tab.

    cFlatPack_7.png

  8. Select the New Instance option to invoke a Java bean
    that is stored in the Code node of the
    Repository.

    In the Bean class field, enter the name of the bean
    class, beans.ReadOrder.class which is just
    created.
  9. Keep the default settings of the cLog
    component to log the message exchanges.
  10. Press Ctrl+S to save your Route.

Viewing code and executing the Route

  1. Click the Code tab at the bottom of the
    design workspace to have a look at the generated code.

    cFlatPack_8.png

    As shown in the code, one route is built from "Delimited_file_cFile_1", to
    "cFlatPack_1". The other is built from
    cFlatPack_2, processed by "cBean_1" and
    "cLog_1" sequentially.
  2. Click the Run view to display it and
    click the Run button to launch the
    execution of your Route. You can also press F6 to execute it.

    cFlatPack_9.png

    RESULT: The delimited file is parsed. The id, first name, and surname of the customer
    information with the corresponding column names is shown in the execution
    console.

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