This post we will generate sample data for further utilisation. In ETL world, if you want to test some components you must need data, but getting a desire sample data is very difficult.
To generate sample data we will use tRowGenerator component which has built in editor where you can select functions or write your won expressions to get expected sample data.
Spte 1: Start writing on Talend designer canvas “trow…” it will show you list of component, from the list select tRowGenerator component.
Note: This is new feature from Talend wherein you don`t need to search component in pallet and then drag and drop.
See in picture.
Step 2: Double click on component and do the setting in tRowGenerator using it`s editor.
- Click on [+] sign to add new column, add new column with name =”name”,
- Select function form “Function” tab on same columns grid.
- Select “TalendDataGenerator.getFirstName” function from function list.
- Add following columns and select the relavant function as we did previously.
- City = TalendDataGenerator.getUsCity
- Now we have 4 columns but we need another one column for Identity number, so add column “ID” with “integer” data type.
- In function Tab select “…” (three dots). You will see function parameters window with single row, down to the columns grid.
- There are three tabs first one “Parameter” is fixed, with no edit option, second on for “value” and last one for “comment”
- Click on value tab it will show you “…” dots then click on it, it opens expression builder for edit. you can add your custom logic here.
- Select “Numeric” routine then select “sequence” keep the default values.
- In “Number of Rows for RowGenerator” text box write value=10. ( we required only ten rows to be generated)
- Click on preview button on below window it will show you generated sample data as a result, it will look like below Image.
For demonstration we have generated only ten rows, but you are free to generate as many as rows you require.
Step 3: Add tLogRow, and connect with tRowGenerator using main flow.
Step 4: Run the job it will show you below result.
If you want to insert this data to the file or database then use the specific compoent e.g. tFileOutputDelimited to store in delimited file.