Skip to main content Skip to complementary content

Defining the input component

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 labelled source_data.

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

    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"
    		}
    	}

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – let us know how we can improve!