Skip to main content Skip to complementary content

Defining the input components to read the scores

Follow the steps below to add and configure the tFileInputDelimited components to the Job script, to read the source data.

Procedure

  1. Create a new Job script, enter an addComponent {} function, and inside this function, enter the setComponentDefinition {} function and its parameters to add the first tFileInputDelimited component:
    	setComponentDefinition {
    		TYPE: "tFileInputDelimited",
    		NAME: "tFileInputDelimited_1",
    		POSITION: 224, 96
    	}
  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.

    In this example, the tFileInputDelimited will read the CSV file that contains the scores of the first month, which has one header row to skip, and the component will be labelled scores_month1

    	setSettings {
    		FILENAME : "\"D:/Talend/Data/Input/scores_month1.csv\"",
    		HEADER : "1",
    		LABEL : "scores_month1"
    	}
    
    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 two columns:

    • subject, type String

    • score, type Double

    	addSchema {
    		NAME: "tFileInputDelimited_1",
    		CONNECTOR: "FLOW"
    		addColumn {
    			NAME: "subject",
    			TYPE: "id_String"
    		}
    		addColumn {
    			NAME: "score",
    			TYPE: "id_Double",
    			PRECISION: 2
    		}
    	}
  4. Use the steps above to add the other two tFileInputDelimited components to read the scores of the second and third months.
    addComponent {
    	setComponentDefinition {
    		TYPE: "tFileInputDelimited",
    		NAME: "tFileInputDelimited_2",
    		POSITION: 224, 192
    	}
    	setSettings {
    		FILENAME : "\"D:/Talend/Data/Input/scores_month2.csv\"",
    		HEADER : "1",
    		LABEL : "scores_month2"
    	}
    	addSchema {
    		NAME: "tFileInputDelimited_2",
    		CONNECTOR: "FLOW"
    		addColumn {
    			NAME: "subject",
    			TYPE: "id_String"
    		}
    		addColumn {
    			NAME: "score",
    			TYPE: "id_Double",
    			PRECISION: 2
    		}
    	}
    }
    
    addComponent {
    	setComponentDefinition {
    		TYPE: "tFileInputDelimited",
    		NAME: "tFileInputDelimited_3",
      	    POSITION: 224, 288
    	}
    	setSettings {
    		FILENAME : "\"D:/Talend/Data/Input/scores_month3.csv\"",
    		HEADER : "1",
    		LABEL : "scores_month3"		
    	}
    	addSchema {
    		NAME: "tFileInputDelimited_3",
    		CONNECTOR: "FLOW"
    		addColumn {
    			NAME: "subject",
    			TYPE: "id_String"
    		}
    		addColumn {
    			NAME: "score",
    			TYPE: "id_Double",
    			PRECISION: 2
    		}
    	}
    }

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 – please let us know!