Defining the input components to read the scores - 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 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 labeled scores_month1

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