Transform and import customers' data to Synerise
Automation capabilities in the area of data transformation can be used to update and change large amounts of data in a fast, advanced way, eliminating the process of manually adjusting the whole file. All transformations are performed on a sample file in desired format.
In this use case, you will find out how to transform and import customer data from a .JSON
file with data transformation and workflows.
In this use case, you will make the following modifications to the sample file:
- Edit values:
- replace the value of the
city
attribute from blank tounknown
; if thecity
attribute is defined, keep the existing city, - replace the
en
,es
,fr
values of thelanguage
attribute withEnglish
,Spanish
,French
, respectively, - replace the value of
payment_cash
andpayment_online
attributes from1
/0
tocash
/Null
andonline
/Null
.
- replace the value of the
- Merge
payment_cash
andpayment_online
attributes into thepayment_info
attribute.
Input data in use case
In this use case, we use two files:
- the complete
.JSON
file with your customer database. Make sure you include one of the required parameters:clientID, uuid, email, customId
. The only requirement for JSON files is that they must be UTF-8 encoded. - Prepare a sample JSON file with data you want to import. Below you will find an example how such a a file can look.
{
"email": "test@test.com",
"city": "",
"language": "fr",
"payment_cash": "1",
"payment_online": "0"
},
{
"email": "test2@test.com",
"city": "New York",
"language": "en",
"payment_cash": "0",
"payment_online": "1"
}
Process
- Prepare data transformation rules to transform the data in the file.
- Prepare a workflow to import the
.JSON
file to Synerise.
Create data transformation rules
In this part of the process, you define the rules of modifying data before sending it to Synerise, so the data is consistent. Each of the following sub-steps describes the individual changes performed on the file.
- Go to Automation > Data Trasnformation > Create transformation.
- Enter the name of the workflow.
Before you proceed with selecting sample data and defining transformation rules, optionally, you can select a goal to help you structure the data. If you want to create a transformation diagram without a specific goal and you know the structure of the output data, skip this step.
Goals will suggest you the required fields needed to perform the import into Synerise.
Add input data
This node 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 Automation workflow, the system uses the rules created with the sample data as a pattern for modifying actual data.
- Click the Add input node on the canvas.
- On the pop-up, click Upload a new file or drag one here.
- Upload the
.JSON
file. - You can preview the file, then click Apply.
Result: The Data input view is filled with data from the sample.
Handle missing data
In this part of the process, you will use the Edit values node to edit the city
attribute values with Jinja code to keep the existing city and add the unknown
value to the blanks.
- Add the Edit values node.
- In the configuration of the node:
-
Click Add rule.
-
Click Add column.
-
Select the
city
column. -
Under Edit values by, from the dropdown list, select Replacing.
-
Under with, from the dropdown list, select Dynamic value.
-
In the Type value field, paste the following Jinja code:
{% if root["city"] != "" %}{{ root["city"] }}{% else %}unknown{% endif %}
As a result, in the Output data tab, you will get an updated file:
-
Change data
In this part of the process you will use the same Edit values node created in the previous part of the process, to also edit the language
, payment_cash
and payment_online
attributes values with jinjava code to change the data. You will change the language
attribute value from “en” to “English” and so on. In case of payment_cash
and payment_online
attributes you will change “1/0“ values to “cash/Null“ and “online/Null” to later merge them into payment_info
attribute.
-
In the configuration of the node:
-
Click Add rule.
-
Click Add column.
-
Select the
language
column. -
Under Edit values by, from the dropdown list, select Replacing.
-
Under with, from the dropdown list, select Dynamic value.
-
In the Type value field, paste the following Jinja code:
{% if root["language"] == "en" %}English{% elif root["language"] == "es"%}Spanish{% elif root["language"] == "fr"%}French{% endif %}
-
-
Click Add rule.
- Click Add column.
- Select the
payment_cash
column. - Under Edit values by, from the dropdown list, select Replacing.
- Under with, from the dropdown list, select Dynamic value.
- In the Type value field, paste the following Jinja code:
{% if root["payment_cash"] == "1" %}cash{% elif root["payment_cash"] == "0"%}{% endif %}
-
Click Add rule.
- Click Add column.
- Select the
payment_online
column. - Under Edit values by, from the dropdown list, select Replacing.
- Under with, from the dropdown list, select Dynamic value.
- In the Type value field, paste the following Jinja code:
{% if root["payment_online"] == "1" %}online{% elif root["payment_online"] == "0"%}{% endif %}
As a result, in the Output data tab, you will get an updated file:
-
Click Apply.
Merge columns
In this part of the process, you will use the Merge columns node to merge payment_cash
and payment_online
attributes into one payment_info
attribute.
-
Click THEN on the canvas.
-
From the dropdown list, select Merge columns node.
-
In the configuration of the node:
-
Click Add rule.
-
Click Add column.
-
Select the
payment_cash
andpayment_online
columns. -
In the Merge values to new column section, in the New column name field, type the name for the new column:
payment_info
. -
Enable the Remove original columns option.
As a result, in the Output data tab, you will get an updated file:
-
-
Click Apply.
-
As the final node, add Data Output in which you will see the final result of file modifications.
-
Click Save and publish.
Prepare a workflow
The scenario for this use case involves a one-time import of .JSON
file with a customer database directly to Synerise.
- Go to Automation > Workflows > New workflow.
- Enter the name of the workflow.
Define the launch date
-
As the trigger node, add Scheduled Run.
-
In the configuration of the node:
- Change the Run trigger option to one time.
- Select Immediately.
- Confirm by clicking Apply.
Select file to import
- Add the Local File node.
- In the configuration of the node:
- Upload the file.
- Confirm by clicking Apply.
Add Data Transformation node
-
Add the Data Transformation node.
-
In the configuration of the node, select the data transformation you have created before.
-
Click Apply
Add Import Profiles and finishing node
-
Add the Import Profiles node.
-
Add the End node.
-
In the upper right corner, click Save & Run.
Check the use case set up on the Synerise Demo workspace
You can check the Data Transformation and Workflow configurations directly in Synerise Demo workspace.
If you don’t have access to the Synerise Demo workspace, please leave your contact details in this form, and our representative will contact you shortly.