LogoLogo
HomeCommunityLangstack.comCreate free account
  • 🤝Welcome
  • 🙌Support
  • 💡Get started
    • 📕Learn Langstack
      • Introduction to Langstack
        • Application templates
        • Storage frameworks
        • Account administration
      • Basics and essentials
        • What is an API gateway?
        • How to work with an API gateway
        • What is an Entity?
        • What is an Action box?
          • How to create and work with Action boxes
          • How to perform search in Actions
        • What is an Action?
          • How to create and work with Actions
          • Error propagation
          • Actions in Langstack applications
        • What is a Data type?
          • Simple Data types
        • What is a Variable?
          • Naming rules of a Variable
        • What is a Function?
          • Working with Functions
        • Navigating to a Variable or a Function
        • Implicit Type Conversion (ITC)
        • Explicit Type Conversion
        • Implicit and Explicit Type Conversion for Json
        • Next Steps
      • User management
        • What is a Privilege?
        • What are Groups?
        • What are Users?
      • Introduction to REST API
        • API Name
        • API Group name
        • Request and Response body
          • Request body
          • How to create and work with a Request body
          • Response body
          • How to create and work with a Response body
        • Query strings
          • How to create and work with Query strings
        • Headers
          • How to create and work with Headers
        • Path parameter
        • Create your first API: "Hello World!"
          • Working with API options
        • Exercise 1: GET REST API & Return Response Object
          • Step 1: Create API
          • Step 2: Test the API
        • Exercise 2: Delete a published API
        • Next Steps
      • Introduction to Entities
        • Fields
        • Records
        • Relations
        • Options for an Entity
        • Exercise 1: Customer Accounts and Activities
          • Customer accounts
            • Step 1: Create the Customers Entity
            • Step 2: Create the API
            • Step 3: Update entity through API
          • Customer Activities
            • Step 1: Create the Activities entity
            • Step 2: Create a “1 to Many” relation
            • Step 3: Create the API
            • Step 4: Update entity through API
        • Exercise 2: Customer Records
          • Step 1: Create the API
          • Step 2: Test the API
        • Next Steps
      • Programming with Entities
        • Create
        • Read
        • Update
        • Delete
        • JXPResponse
        • Next Steps
      • Using Triggers
        • After Create Trigger
        • After Update Trigger
        • After Delete Trigger
        • Exercise: Entity & Entity triggers
        • Step 1: Define “After Create” Trigger
        • Step 2: Define “After Update” Trigger
      • Connectors
        • Create a connector
        • SFTP Connector
        • MySQL Connector
        • Next Steps
      • Introduction to ETL pipeline
        • Create an ETL pipeline
        • Data Formats in ETL pipeline
          • Reader
          • Writer
          • Field mapping
        • Shared variables for ETL pipeline
        • ETL functions execution sequences overview
        • Displaying Functions
        • How to perform Search in ETL pipeline
        • Exercise 1: Skip Customer records
          • Step 1: Create the ETL pipeline
          • Step 2: Skip records based on Customer_ID
          • Step 3: Store skipped records in a list
          • Step 4: Store the Skipped Customer record
        • Exercise 2: ETL pipeline, CSV source & FTP Connector
        • Exercise 3: ETL pipeline, Database Source & MySQL Connector
        • Exercise 4: ETL pipeline, CSV Source & FTP Connector using Sections
          • Step 1: Create the ETL pipeline
          • Step 2: Reformat the Join_Date Values and define added fields
      • Multiple Executions, Time Duration, Linked App and Execution Status
        • Skip execution while in progress
        • Time duration settings
        • Linked App
        • Options for Delay Types
        • Execution status
      • Validation pipeline
        • Sequence of Validation pipeline
        • Exercise: Customer Information
          • Step 1: Create a Validation pipeline
          • Step 2: Create the API gateway
          • Step 3: Test the Validation pipeline
      • Introduction to Process
        • Create a process
        • Shared variables for a process
        • Exercise: Customer Anniversary Email Activity
          • Step 1: Check if the join date matches the current date
          • Step 2: Test the Process
      • Introduction to Flows & Flow components
        • What is a Flow?
        • What is a Flow component?
          • What is a Flow component Event?
        • Exercise 1: Customer Anniversary Email
          • Step 1: Create the Flow component
          • Step 2: Create the Flow
          • Step 3: Trigger the Flow
          • Step 4: Check records in the target entity
        • Exercise 2: Store list of customers
          • Step 1: Create the Flow component
          • Step 2: Create the Flow
          • Step 3: Create the API
    • 🌍Tour of Langstack (coming soon)
  • 📘In depth learning
    • 📖User Manual (coming soon)
    • 🔗Connectors
      • MS-SQL connector
        • Data type conversions between Langstack and MSSQL
        • Handling data loss in data type conversions
        • Setting up MS-SQL connector
        • MS-SQL connector as Reader and Writer
        • Using MS-SQL connector in ETL pipeline
          • MS-SQL connector as a source
          • MS-SQL connector as a destination
      • Google Drive connector
        • Set up Google Drive Connector
        • Adding Google Drive path in ETL pipeline Streams
        • Setting up GCP Account, GCP Project, API Enablement, and Credentials (Prerequisites)
          • OAuth 2.0 Client Credentials
          • Service Account Key Credentials
          • API Key Credentials
          • Authorization through Redirect URLs
        • Using Google Drive connector in ETL pipeline
          • Specifying file or folder paths
            • Direct file link
            • Folder link and file name
            • Folder path and file name
            • Folder path excluding file name
            • Folder path including file name
          • Google Drive connector as a source
          • Google Drive connector as a destination
      • AWS connector
        • Introduction
        • Set up AWS S3 Connector
          • OAuth 2.0 Client Type
          • Access Key
          • Public
        • Setting up AWS Account
          • Retrieve Client ID and Client Secret
        • Set up Amazon Web Services (Cognito) Console
          • Retrieve Identity Pool Id
          • Manage Permissions for Roles
          • Adding Redirect URL in Amazon Developer Console
          • User Consent for OAuth 2.0 Client through Login with Amazon
          • Retrieve Access Key Credentials
        • Creating a bucket in AWS
        • Using S3 connector in ETL pipeline
          • Specifying paths
          • Examples
            • AWS S3 connector as a source
            • AWS S3 connector as a destination
      • OneDrive connector
        • Set up OneDrive Connector
        • Setting up Microsoft Azure Account
        • Add URL to Authorized Redirect URLs
        • User Consent for Establishing OneDrive Connection
        • Usage of OneDrive Connector in ETL pipeline
          • Examples
          • OneDrive connector as a source
          • OneDrive connector as a destination
      • Dropbox connector
        • Set up Dropbox Connector
        • Setting up Dropbox Account
        • Add URL to Authorized Redirect URLs
        • User Consent for Establishing Dropbox Connection
        • Usage of Dropbox connector in ETL pipeline
          • Dropbox connector path settings
          • Examples
            • Dropbox connector as a source
            • Dropbox connector as destination
  • 🗃️Use Cases (Coming soon)
    • Use Case 1
    • Use Case 2
    • Use Case 3
Powered by GitBook
On this page
  1. Get started
  2. Learn Langstack
  3. Introduction to ETL pipeline
  4. Exercise 4: ETL pipeline, CSV Source & FTP Connector using Sections

Step 2: Reformat the Join_Date Values and define added fields

PreviousStep 1: Create the ETL pipelineNextMultiple Executions, Time Duration, Linked App and Execution Status

Last updated 2 years ago

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.

💡
📕