Step 2: Reformat the Join_Date Values and define added fields

The joining date for the customer in this file is in the format (M/DD/YYYY), whereas the format of the Join_Date in the entity is (MM/DD/YYYY). The date format must be reformatted before storing it in the entity. The second step of this exercise is

  1. Reformat the Join_Date values.

  2. Assign values to the added fields (DateMonthJoinDate, Customer_Value, and Rating).

  • To define the actions, go to the Code tab>On Reading record function and expand it. To add an โ€œAction boxโ€, click the [+ Action box] button.

  • In this Action box, the format of the join date will be aligned to the format of the destination entity. To give it a more meaningful label, click on the text and enter the text as โ€œfix join date fieldโ€.

  • To define the variables to store values in this Action box, go to the โ€œVariablesโ€ tab and add a new variable by clicking the [+ Variable] button.

  • To store the โ€œJoin_Dateโ€ value in the Reader as string before reformatting it, define the first variable as follows: Variable name: โ€œstrListโ€, Data Type: โ€œstringโ€, Select the โ€œ[List]โ€ checkbox. It displays as โ€œListโ€. This defines the variable to store a list of strings.

  • To store the value of the Day from the โ€œJoin_Dateโ€, add and define the second variable as follows: Variable name: โ€œstrDayโ€, Data Type: โ€œstringโ€

  • To store the value of the Month from the โ€œJoin_Dateโ€, add and define the third variable as follows: Variable name: โ€œstrMonthโ€, Data Type: โ€œstringโ€

  • To store the value of the Year from the โ€œJoin_Dateโ€, add and define the fourth variable as follows: Variable name: โ€œstrYearโ€, Data Type: โ€œstringโ€

  • To store the value of the adjusted DateTime of the โ€œJoin_Dateโ€, add and define the last variable of the โ€œAction boxโ€ as follows: Variable name: โ€œadjustedDateTimeโ€, Data Type: โ€œstringโ€

  • To define the actions in the โ€œAction boxโ€, go to the โ€œCodeโ€ tab and add an Action.

  • To define the action to store the Join_Date as a list of strings:

    1. Select Action as โ€œSplit stringโ€.

    2. Select Target Value as โ€œstrListโ€.

    3. Select Source as Variables>reader>Join_Date. It displays as โ€œreader.Join_Dateโ€.

    4. Enter Delimiter as โ€œ/โ€ (without quotes). (the date format in the source file is โ€œd/mm/yyyy hh:mm:ssโ€, hence, the list will be created by separating the digits based on the โ€œ/โ€)

  • To update the month's value (first part of the list of strings) into a variable, add and define the second Action as follows:

    1. Select Action as โ€œUpdate Variableโ€.

    2. Select Target Value as โ€œstrMonthโ€.

    3. Select Value as Variables>strList>getFirst(). It displays as โ€œstrList.getFirst()โ€.

  • To update the format of the โ€œstrMonthโ€ value to align it with that of the โ€œJoin_Dateโ€ in the entity, i.e., convert the format from โ€œm/โ€ to โ€œmm/โ€, add and define the third Action:

    1. Select Action as โ€œCondition actionโ€.

    2. Enter the description as โ€œif month is one digitโ€.

  • To define the criteria, go to the โ€œCriteriaโ€ tab in the โ€œCondition actionโ€ and add a new Criteria bar.

  • Define the Criteria bar to check the value of โ€œstrMonthโ€ is less than 2 digits:

    1. Select Source as Variables>strMonth>length(). It displays as โ€œstrMonth.length()โ€.

    2. Select Operator as โ€œIs Equalโ€.

    3. Enter Integer value as โ€œ1โ€ and press Enter.

  • To define the action if the Criteria Bar returns true, go to the Code tab>On True section. Add and define the action to update the โ€œstrMonthโ€ variable with a โ€œ0โ€ placed before the value:

    1. Select Action as โ€œUpdate Variableโ€.

    2. Select Target Value as โ€œstrMonthโ€.

    3. Select Source as follows to concatenate the โ€œ0โ€ with the value of โ€œstrMonthโ€:

      1. Enter the digit โ€œ0โ€ (without quotes) and press Enter.

      2. Select Variables>strMonth. The source field displays as โ€œ0โ€โ€œstrMonthโ€.

  • To store the second item of list of strings (day's value) in the variable โ€œstrDayโ€, add and define an action after the โ€œCondition actionโ€ as follows:

    1. Select Action as โ€œGet List itemโ€.

    2. Select Target Value as โ€œstrDayโ€.

    3. Select Source as Variables>strList. It displays as โ€œstrListโ€.

    4. Enter the index position as โ€œ1โ€ (without quotes) and press Enter.

  • To update the format of the โ€œstrDayโ€value to align it with that of the โ€œJoin_Dateโ€ in the entity i.e convert the format from โ€œd/โ€ to โ€œdd/โ€, add and define the third action:

    1. Select Action as โ€œCondition actionโ€.

    2. Enter the description as โ€œif day is one digitโ€.

  • To define the criteria for the โ€œCondition actionโ€, go to the โ€œCriteriaโ€ tab in the โ€œCondition actionโ€ and add a new Criteria bar.

  • Define the Criteria bar to check the value of โ€œstrDayโ€ is less than 2 digits:

    1. Select Source as Variables>strDay>length(). It displays as โ€œstrDay.length()โ€.

    2. Select Operator as โ€œIs Equalโ€.

    3. Enter Integer value as โ€œ1โ€ and press Enter.

  • To define the action if the Criteria bar returns true, go to the Code tab>On True section, add and define the action to update the โ€œstrDayโ€ variable with a โ€œ0โ€ placed before the value:

    1. Select Action as โ€œUpdate Variableโ€.

    2. Select Target Value as โ€œstrDayโ€.

    3. Select Value as follows to concatenate the โ€œ0โ€ with the value of โ€œstrDayโ€:

      1. Enter the digit โ€œ0โ€ (without quotes) and press Enter.

      2. Select Variables>strDay. It displays as โ€œstrDayโ€. The source field displays as โ€œ0โ€โ€œstrDayโ€.

  • To separate values of the year and time, the last part of the first list of strings needs to be split further. After the Condition action, add and define the Action as follows:

    1. Select Action as โ€œSplit stringโ€.

    2. Select Target Value as โ€œstrListโ€.

    3. Select the Source as Variables>strList>getLast(). It displays as โ€œstrList.getLast()โ€.

    4. Enter the Delimiter as โ€œ โ€ (space without quotes). (The list of strings to split is the last part of the first string i.e. โ€œyyyy hh:mm:ssโ€, hence, the list of strings will be created by separating the values based on the โ€œ(space)โ€.)

  • To update the year's value (first part of the list of strings created in the previous step) into a variable, add and define the second action as follows:

    1. Select Action as โ€œUpdate Variableโ€.

    2. Select Target Value as โ€œstrYearโ€.

    3. Select the Value as Variables>strList>getFirst(). It displays as โ€œstrList.getFirst()โ€.

  • To update the values of day, month and year in the Join_Date read by the Reader into the format of the Join_Date field in the entity (yyyy-mm-dd hh:mm:ss), add and define an Action as follows:

    1. Select Action as โ€œUpdate Variableโ€.

    2. Select Target Value as reader>Join_Date(). It displays as โ€œreader.Join_Date()โ€.

    3. Select Value as follows:

      1. Select Variables>strYear. It displays as โ€œstrYearโ€.

      2. Type โ€œ-โ€ (without quotes) and press Enter.

      3. Select Variables>strMonth. It displays as โ€œstrMonthโ€.

      4. Type โ€œ-โ€ (without quotes) and press Enter.

      5. Select Variables>strDay. It displays as โ€œstrDayโ€.

      6. Type โ€œ(space)โ€ (without quotes) and press Enter.

      7. Type โ€œ00-00-00โ€ (without quotes) and press Enter. The Source value displays as โ€œstrYearโ€โ€œ-โ€โ€œstrMonthโ€โ€œ-โ€โ€œstrDayโ€โ€œ(space)โ€โ€œ00-00-00โ€

  • To update the values of the Day and Month in the reader field of โ€œDayMonthJoinDateโ€, add and define an Action as follows:

    1. Select Action as โ€œUpdate Variableโ€.

    2. Select Target Value as reader>DayMonthJoinDate().

    3. Select Value as follows:

      • Select Variables>strDay. It displays as โ€œstrDayโ€.

      • Select Variables>strMonth. It displays as โ€œstrMonthโ€.

      The Source value displays as โ€œstrDayโ€โ€œstrMonthโ€.

  • To assign a value to โ€œCustomer_Valueโ€ field added to the Reader, add and define an Action as follows:

    1. Select Action as โ€œUpdate Variableโ€.

    2. Select Target Value as reader>Customer_Value. It displays as โ€œreader.Customer_Valueโ€.

    3. Type the Value as โ€œ0โ€ and press Enter.

  • To assign a value to โ€œRatingโ€ field added to the Reader, add and define an Action as follows:

    1. Select Action as โ€œUpdate Variableโ€.

    2. Select Target Value as reader>Rating. It displays as โ€œreader.Ratingโ€.

    3. Type the Value as โ€œ1โ€ and press Enter.

  • To save the ETL pipeline, click [Save].

  • To publish the ETL pipeline, click [Publish].

  • Ensure the ETL pipeline is enabled.

  • Click the [Run] button.

  • The Run ETL pipeline dialog box displays. Click [Run] to execute the ETL pipeline.

  • The ETL pipeline will run on the date and time specified. The records will be added to the destination file.

  • The data will be updated from the source to destination. To verify, check the target entity. The data from the file will be updated in the target entity along with the added fields for DayMonthJoinDate, Customer_Value, and Rating.

Last updated