Data Cleansing

Creating a Data Cleansing Workflow in HGrid247-3.5

In HGrid247 version 3.5, workflows are used to describe the flow of data processing from source to final destination . Workflows typically consist of three main components: This workflow is often run on Big Data platforms such as: In this guide, a workflow is created to clean (data cleanse) a YouTube video dataset .

Step 1 – Create a new workflow

The first step is to create a new workflow.
The steps:

Enter the workflow name:
    Lab01
After pressing Finish , a workflow canvas will appear to draw the data processing flow.


Step 2 – Define Source Data dan Assembly

At this stage we determine the data sources and initial transformation processes. .
The steps:


Then create a link from, pushing-and-holding left mouse-button on Hfs Source, move to Transformator and release the mouse:
    Hfs Source → Transformator
Link created with:

Step 3 – Transform Text Line into Record

The goal of the first transformer is to break a CSV text line into records with specific fields. .

Fields created:
    video_id
    title
    channel_title
    category_id
    tags
    views
    likes
    dislikes
    comment_total
    thumbnail_link
    date
The steps:


Then use the RegexSplitter transformation function transformation function .
Steps: Click right mouse button on RegexSplitter
Then select:
    Link To All Output Fields
Then click :
    OK



This function splits CSV rows into columns.

Step 4 – Removing Invalid Records

At this stage we remove data that does not have a video_id .
Steps:


Double click filter_1
Create conditions:
    video_id is not null



The goal is to remove empty or invalid records.

Step 5 – Value Transformation and Date Format

At this stage some data cleaning is done.
Transformations carried out:
    Field               Transformation
    views               '' → 0
    likes               '' → 0
    dislikes            '' → 0
    comment_total	'' → 0
    date                change the format to YYYYMMdd
Steps: Then do the following transformation.

Replacing Empty Values to 0

Use the NVL function .
Steps: Do the same steps for:
    likes
    dislikes
    comment_total
Then change the data type to Integer .



Changing the Date Format

Initial date format:
    13.09
Become:
    20170913
Transformation steps: Then do the following transformation:

Step 6 – Adding a Sink

The final stage is to determine the purpose of data storage .
Steps:

This sink will save the results to HDFS on the system:

Step 7 – Compile dan Generate Workflow

Once the workflow is created: This process will produce the following file:
    workshop_mr.jar


Step 8 – Running Workflow on Hadoop Cluster

First upload data to HDFS.
    hadoop fs -put youtube_videos.csv /hduser/youtube
Then run the workflow:
hadoop jar workshop_mr.jar workshop.Lab01 /hduser/youtube /hduser/youtube_out
The workflow will run the data cleansing process on the YouTube dataset .



Output Results

The output of the workflow contains data that has been: Data is stored in the directory:
    /hduser/youtube_out

Note : The file of workflow Labs01 can be found in the following link : Lab01.csd