Generate sample data in Talend

Generate sample data in Talend
3.75 (75%) 4 votes

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.

Add Component writing  on Talend Designer pan
Add Component writing on Talend Designer pan

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
    • State=TalendDataGenerator.getUsState
    • Street=TalendDataGenerator.getUsStreet
  • 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.
tRowGenerator setting
tRowGenerator setting

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.

tRowGenerator output sample data
tRowGenerator output sample data

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.

About Umesh

I am Software consultant with approx 7 years of experience mainly in Business Intelligence and data warehousing assignments using Talend. Writing is not my passion but i am doing it to help others. if you have any special case where you want me to demonstrate then please post me.

3 comments on “Generate sample data in Talend

    1. Hi Amol,

      writing json is a complex process, i would suggest use data Mapper from enterprise version of Talend, if you put some example here i can suggest you better way. add any example values for demonstration.

Leave a Reply to dwetl Cancel reply

Your email address will not be published. Required fields are marked *