## Related terms

- data\-transformation
- workflow
- local\-file
- automation\-module

See the [glossary](/glossary.md) for definitions.

---

# Cleaning and Transforming Data for Optimal Business Performance


The better quality data you have at your disposal, the better the actions and analyses you perform on that data. 

However, the data you have is not always in a state ready for analysis. The files may contain redundant or incorrect data. There may also be duplicate or missing values. 

To make sure that the data you want to use in your activities and analyses is properly prepared, it is a good idea to clean data before using it. Automation Hub comes to your aid. It gives you the ability to perform a large number of operations on any data you need to modify. 

This use case describes the process of transformation of a CSV file with electronic card transactions. The data transformations performed in this use case consist of:
- removing columns with missing data
- adding missing data
- removing structural errors by adding suffixes
- filtering rows

After transformation, the file will be transferred to an SFTP server.

## Prerequisites
---

- Save the file which you want to transform to your computer.
- You must have a target resource with which you transfer the data (in this use case, an SFTP server is used).
- Make a copy of the data file and remove rows from the copy until 10 are left. This copy will be used only as a sample for configuring the Data Transformation rules.

## Process
---

1. [Prepare transformation](/use-cases/data-cleaning#create-transformation) to modify the data to meet the requirements of the external resource data structure.  
2. [Prepare a workflow](/use-cases/data-cleaning#prepare-a-workflow) that sends the data of customers from Synerise to the external resource.

## Create transformation
---

In this part of the process, you define the rules of modifying data before sending it to the SFTP server, so the data is consistent. Each of the following sub-steps describes the individual changes performed on the file. 

The data transformation diagram which is the output of this part of the process is used later to [automate sending the data](/use-cases/data-cleaning#prepare-a-workflow).

1. Go to <img src="/api/docs/image/219f337699cf7b17198d03b7a7c7f148886e25a1/icons/automation-hub-icon.svg" alt="Automation Hub icon" class="icon" > **Automation Hub > Transformations > New transformation**.  
2. Enter the name of the transformation.  
3. Click **Upload a new file or drag one here**.  

### Add file with sample data

This step allows you to add a data sample. In further steps, you define how the data must be modified. Later, when this transformation is used in the workflow, the system uses the rules created with the sample data as a pattern for modifying actual data.
 
1. Upload the file with the sample data. 
2. Provide **Delimiter**, **Quotation mark** and **Escape character**. 
3. Click **Apply**.  

<figure><img src="/api/docs/image/219f337699cf7b17198d03b7a7c7f148886e25a1/use-cases/all-cases/_gfx/data-input.png" class="full" alt="Transformations Uploading sample data for data cleaning"><figcaption>The configuration of the file upload</figcaption></figure>

### Remove irrelevant data

In this part, use the **Remove Columns** step, to remove the columns that do not contain data, these are the columns named: **Series_title_3** and **Series_title_4**. 

1. On the right panel, click **App step**.  
2. From the dropdown list, select **Remove Columns**.
3. In the configuration of the step:  
    1. Leave the **Remove** option selected in the dropdown menu.
    2. Leave the default value in the dropdown as **Equal**.
    3. In the text field, enter the name of the empty column you want to remove - `Series_title_3`.  
    4. Click **Add condition**. 
    5. Repeat steps **3.b-d** to define all the columns you want to delete.   
        <figure><img src="/api/docs/image/219f337699cf7b17198d03b7a7c7f148886e25a1/use-cases/all-cases/_gfx/filter-columns.png" class="full" alt="The configuration of the Remove Columns step"><figcaption>The configuration of the Remove Columns step</figcaption></figure>  

        This resulted in the removal of columns **Series_title_3** and **Series_title_4**:
        <figure><img src="/api/docs/image/219f337699cf7b17198d03b7a7c7f148886e25a1/use-cases/all-cases/_gfx/filter-columns-output-data.png" class="full" alt="Output data after applying Remove Columns step"><figcaption>Output data after applying Remove Columns step</figcaption></figure>     
    6. Confirm by clicking **Apply**. 

### Handle missing data

Use the **Edit Values** step that allows you to perform basic actions on the dataset.   
    In this example, handle missing data in the **Suppressed** column by replacing its contents (in this example, the column is empty) with the value `false`.

1. On the right panel, click the **Add step**.  
2. From the dropdown list, select **Edit Values**.
3. Click the **Edit Values** step.  
4. In the configuration of the step:  
    1. Select the **Suppressed** column.  
    2. Under **Edit values by**, from the dropdown list, select **Replacing**.  
    3. In the dropdown below, leave the **Static value** option at default.  
    4. In the text field, enter `false`.  
            <figure><img src="/api/docs/image/219f337699cf7b17198d03b7a7c7f148886e25a1/use-cases/all-cases/_gfx/edit-values.png" class="full" alt="The configuration of the Edit Values step"><figcaption>The configuration of the Edit Values step</figcaption></figure> 
        As a result, you will get an updated file:
            <figure><img src="/api/docs/image/219f337699cf7b17198d03b7a7c7f148886e25a1/use-cases/all-cases/_gfx/edit-values-output.png" class="full" alt="Output data after applying Edit Values step"><figcaption>The configuration of the Edit Values step</figcaption></figure>  
     5. Confirm by clicking **Apply**. 

### Fix structural errors

Structural errors are when you notice strange naming conventions, typos, or incorrect capitalization when measuring or transmitting data.   
    Use **Edit Values** step to make the format of the data in the column **Data_value** consistent. Currently, in the **Data_value** column, the data appears both as number `36422` and float `33317.4`. To make the data consistent, unify the data to float.

1. On the right panel, click the **Add step**.  
2. From the dropdown list, select **Edit Values**.
3. Click the **Edit Values** step.  
4. In the configuration of the step:
    1. Select the **Data_value** column.
    2. Under **Edit values by**, from the dropdown list, select **Adding suffix**.
    3. In the text field, enter `.0`.
    4. Click **If current value**.
    5. From the dropdown list select **Not contain**.
    6. In the text field provide `.`.
        <figure><img src="/api/docs/image/219f337699cf7b17198d03b7a7c7f148886e25a1/use-cases/all-cases/_gfx/edit-values-suffix.png" class="full" alt="The configuration of the Edit Values step"><figcaption>The configuration of the Edit Values step</figcaption></figure> 
        As a result, you will get an updated file:
        <figure><img src="/api/docs/image/219f337699cf7b17198d03b7a7c7f148886e25a1/use-cases/all-cases/_gfx/edit-values-suffix-output.png" class="full" alt="Output data after applying Edit Values step"><figcaption>The configuration of the Edit Values step</figcaption></figure>  
     7. Confirm by clicking **Apply**. 

### Filter records

To filter records from the data, use the **Filter Rows** step.  
    In this case, keep only records where the value of the **UNIT** column is equal to `Dollars`.

1. On the right panel, click **Add step**.  
2. From the dropdown list, select **Filter Rows**.
3. Click the **Filter Rows** step.  
4. In the configuration of the step:  
    1. Select the **UNITS** column.
    2. Under **Where value**, from the dropdown list, select **Contain**.
    3. In the text field, enter `Dollars`.
        <figure><img src="/api/docs/image/219f337699cf7b17198d03b7a7c7f148886e25a1/use-cases/all-cases/_gfx/filter-rows.png" class="full" alt="The configuration of the Filter Rows step"><figcaption>The configuration of the Filter Rows step</figcaption></figure> 
        As a result, you will get an updated file:
            <figure><img src="/api/docs/image/219f337699cf7b17198d03b7a7c7f148886e25a1/use-cases/all-cases/_gfx/filter-rows-output.png" class="full" alt="Output data after applying Filter Rows step"><figcaption>The configuration of the Filter Rows step</figcaption></figure>  
     4. Confirm by clicking **Apply**.  

### Add the finishing step

This step lets you preview the output of the modifications to the sample data.

1. Preview the results in the **Output** tab.
    <figure><img src="/api/docs/image/219f337699cf7b17198d03b7a7c7f148886e25a1/use-cases/all-cases/_gfx/final-data-preview.png" class="full" alt="The preview of modifications to the file"><figcaption>The preview of modifications to the file</figcaption></figure>
2. In the upper right corner, click **Save**.  
    **Result**:  
    <figure><img src="/api/docs/image/219f337699cf7b17198d03b7a7c7f148886e25a1/use-cases/all-cases/_gfx/final-data-transformation.png" class="full" alt="Data Transformation configuration for cleaning customer data"><figcaption>The configuration of data transformation</figcaption></figure>

## Prepare a workflow 
---

The scenario for this use case involves a one-time transformation of a file uploaded from the user's local storage. The transformed data will be exported to the external source using the SFTP protocol. 

1. Go to <img src="/api/docs/image/219f337699cf7b17198d03b7a7c7f148886e25a1/icons/automation-hub-icon.svg" alt="Automation Hub icon" class="icon" > **Automation Hub > Workflows > New workflow**.  
2. Enter the name of the workflow.  

### Define the launch date

1. As the trigger node, add **Scheduled Run**.  
2. In the configuration of the node:  
    1. Select the **Run once** option.
    2. Select **Immediately**.
        <figure><img src="/api/docs/image/219f337699cf7b17198d03b7a7c7f148886e25a1/use-cases/all-cases/_gfx/scheduled-run-dt.png" class="full" alt="Automation Hub Scheduled Run node configuration for triggering data cleaning operations"><figcaption>The configuration of the Scheduled Run node</figcaption></figure>
    3. Confirm by clicking **Apply**.

### Select file to export

1. Add a **Local File** node.  
2. In the configuration of the node:  
    1. Upload the file in which you want to perform the transformation.  
        <figure><img src="/api/docs/image/219f337699cf7b17198d03b7a7c7f148886e25a1/use-cases/all-cases/_gfx/local-file-dt.png" class="full" alt="Local File transfer"><figcaption>Local File transfer</figcaption></figure>    
    2. Confirm by clicking **Apply**.  

### Select the transformation

1. Add a **Data Transformation Studio** node.  
2. In the configuration of the node, keep the default **From workflow context** option.
3. Click **Templates library**:
    1. Select the [transformation you have created before](/use-cases/data-cleaning#create-transformation).  
        <figure><img src="/api/docs/image/219f337699cf7b17198d03b7a7c7f148886e25a1/use-cases/all-cases/_gfx/transformation-template.png" class="full" alt="The configuration of the transformation template"><figcaption>The configuration of the transformation template</figcaption></figure>
    2. Click the **Use template** button.

<figure><img src="/api/docs/image/219f337699cf7b17198d03b7a7c7f148886e25a1/use-cases/all-cases/_gfx/data-transformation-workflow.png" class="full" alt="The configuration of the Data Transformation Studio node"><figcaption>The configuration of the Data Transformation Studio node</figcaption></figure>

4. Confirm by clicking **Apply**.

### Configure settings for SFTP protocol

1. Add the **Send File** node by clicking **THEN > SFTP**.  
2. In the configuration of the node:  
    1. Choose SFTP connection type:
        1. Select **Public-key**.
        2. Below, choose desired item in the **select connection** field.
            <figure><img src="/api/docs/image/219f337699cf7b17198d03b7a7c7f148886e25a1/use-cases/all-cases/_gfx/sftp-connection-key.png" class="full" alt="The configuration of the SFTP connection type"><figcaption>The configuration of the SFTP connection type</figcaption></figure>
        3. Click **Next**.
    2. Enter the path to your server.  
    3. Select the port.
    4. Enter the path to the directory.
    5. Enter the name of the file that will be created.  
    6. If needed, in the **File name suffix**, select the suffix of the file name.  
    7. From the **File format** dropdown list, select the **CSV** format.  
    8. Verify and modify the delimiters if needed.  
        <figure><img src="/api/docs/image/219f337699cf7b17198d03b7a7c7f148886e25a1/use-cases/all-cases/_gfx/data-cleaning-sftp.png" class="large" alt="The configuration of the SFTP node"><figcaption>The configuration of the SFTP node</figcaption></figure>
    9. Confirm by clicking **Apply**. 

### Add the finishing node

1. Add the **End** node. 
2. In the upper right corner, click **Save & Run**.  
    <figure><img src="/api/docs/image/219f337699cf7b17198d03b7a7c7f148886e25a1/use-cases/all-cases/_gfx/workflow-dt.png" class="full" alt="Automation Hub workflow for data cleaning operations"><figcaption>The workflow configuration</figcaption></figure>

## Check the use case set up on the Synerise Demo workspace
---

You can check the [transformation](https://app.synerise.com/automations/data-transformation/bdf77aad-e443-4630-931d-af944f814db3) and [workflow](https://app.synerise.com/automations/automation-diagram/811d3a5b-64c4-4cba-9d93-64add71a7f23) directly in Synerise Demo workspace.

If you’re our partner or client, you already have automatic access to the **Synerise Demo workspace (1590)**, where you can explore all the configured elements of this use case and copy them to your workspace.  

If you’re not a partner or client yet, we encourage you to fill out the contact [form](https://demo.synerise.com/request) to schedule a meeting with our representatives. They’ll be happy to show you how our demo works and discuss how you can apply this use case in your business.

## Generated events

This use case generates approximately 5 events per workflow execution:
[`automation.clientStartPath`](/docs/assets/events/event-reference/automation#automationclientstartpath) (~1), [`automation.clientPathStep`](/docs/assets/events/event-reference/automation#automationclientpathstep) (~3), [`automation.clientEndPath`](/docs/assets/events/event-reference/automation#automationclientendpath) (~1).

## Read more
---

- [Data Transformation](/docs/automation/data-transformation-and-imports/introduction)
- [Workflow](/docs/automation)