Defining the input component - Cloud - 8.0

Talend Job Script Reference Guide

Version
Cloud
8.0
Language
English
Product
Talend Big Data
Talend Big Data Platform
Talend Cloud
Talend Data Fabric
Talend Data Integration
Talend Data Management Platform
Talend Data Services Platform
Talend ESB
Talend MDM Platform
Talend Real-Time Big Data Platform
Module
Talend CommandLine
Talend Studio
Content
Design and Development > Designing Jobs
Last publication date
2024-02-22

Follow the steps below to add and configure the component used in this example.

Procedure

  1. In the Job script editor, enter an addComponent {} function and its setComponentDefinition {} sub-function to add the input component, tFileInputDelimited.
    // read input data
    addComponent {
    	setComponentDefinition {
    		TYPE: "tFileInputDelimited",
    		NAME: "tFileInputDelimited_1",
    		POSITION: 160, 192
    	}
    }
  2. Next to the setComponentDefinition {} function, enter the setSettings {} function to specify the path to the source file, the number of header and footer rows to skip, and optionally the label of the component displayed in the design workspace.

    As shown below, this component will read a CSV file named sampleRecords.csv, which has a header row and a footer row to skip, and the component will be labeled source_data.

    	setSettings {
    		FILENAME : "\"E:/Talend/Data/Input/sampleRecords.csv\"",
    		HEADER : "1",
    		FOOTER : "1",
    		LABEL : "source_data"
    	}
    Warning:

    Be sure to use a backslash (\) when specifying a metacharacter.

  3. Next to the setSettings {} function, enter in an addSchema {} function and its addColumn {} sub-functions to define the component schema.

    In this example, the source file has five columns, all being non-nullable:

    • name, type String

    • gender, type String

    • age, type Integer, two characters long

    • city, type String

    • marriageStatus, type String

    	addSchema {
    		NAME: "tFileInputDelimited_1",
    		CONNECTOR: "FLOW"
    		addColumn {
    			NAME: "name",
    			TYPE: "id_String"
    		}
    		addColumn {
    			NAME: "gender",
    			TYPE: "id_String"
    		}
    		addColumn {
    			NAME: "age",
    			TYPE: "id_Integer",
    			LENGTH: 2
    		}
    		addColumn {
    			NAME: "city",
    			TYPE: "id_String"
    		}
    		addColumn {
    			NAME: "marriageStatus",
    			TYPE: "id_String"
    		}
    	}