When transferring data from one system to another, there is often a difference in the data schema, particularly in field naming. For example, in your CSV input file, a column could be named Address, while in your target system, the corresponding field might be called Primary Address.
In traditional programming, you might make a data mapping function to convert from one data structure to another, perhaps using something like AutoMapper, if you've worked in c#.
In Synatic, there is a Field Mapper Step to help with this task. The Field Mapper Step can convert from one field name to another, convert data types, and perform templating, combining, and formatting field values through Handlebars.
Adding the Field Mapper Step
The Field Mapper Step is located in the Mapper drawer in the Steps palette. To use a Field Mapper Step in your flow, drag it onto the desired location in the flow, and fill out the mapping table:
Configuring the Field Mapper Step
Mapping Table
The mapping table has 5 columns. Not every column is needed for mapping; it all depends on the object to achieve.
It's easiest if we go through the columns from right to left:
Type
This specifies the data type of the newly mapped value. Synatic will try parse and convert where possible.
Default Value
This is a default value to use in the new field if there is no source field found on the input record.
To Path
This field is mandatory. This specifies the path or name of the new field to map to.
From Path
The From Path column specifies a path to an existing field on the record to map from. You can use dot notation to specify sub-properties if you need them. If you specify a From Path, you don't need to specify a From Value.
From Value
The From Value allows you to use a Handlebars template to specify a value to map to your new field (specified in the To Path). This allows you to combine values, format values, and more.
Options
The Field Mapper has the "Clean Record" option:
Enabling Clean Record will create a new "clean" record, with only the new fields specified in the "To Path" column of the mapping table.
Disabling Clean Record will append the new fields specified in the "To Path" column of the mapping table to the existing record.
In short, use the Clean Record option if you need a totally new schema and record.
Example
For the examples that follow, let's assume our input record looks like this:
{
Rank : 1,
Name : "Wii Sports",
Platform : "Wii",
Year : "2006",
Genre : "Sports",
Publisher : "Nintendo",
Sales :{
NA_Sales : 41.49,
EU_Sales : 29.02,
JP_Sales : 3.77,
Other_Sales : 8.46,
Global_Sales : 82.74
}
}
Mapping to a clean record, with new field names
Let's assume we want to map from the above input records to a totally new simplified schema that looks like this:
{
Game_Name: string,
Platform_Name : string,
Release_Date : date,
Total_Sales : numeric
}
We mainly want new field names and to convert the Year field to a date-time. The mapping table and options to achieve the transform would look like this:
Using the From Value template
Let's say we need a new field that is a "Full Name" for certain display purposes. This would be a combination of the game name and the publisher. So for our input example at the top, we'd want a field called FullName and the value to be "Wii Sports by Nintendo". To achieve this, we can use Handlebars templates and the From Value mapping column:
Note that the "Clean Record" option is off in this case, as we want to append this new field to our existing record. Also, note in the Handlebars template that we use "record" before referencing the fields of interest. {{record.Name}} by {{record.Publisher}}
Advanced Mode Options
None.
Limitations and known issues
None.
See Also
Read more about Super Mapper.
Useful Tutorials
Revisit the Getting Started page for a refresher.
Read more about Steps here.