No results found
We couldn't find anything using that term, please try searching for something else.
mappingON THIS PAGE The mapping prefix is used to create a mapping table that can be used to, for example, replacing field values and field names dur
The mapping prefix is used to create a mapping table that can be used to, for example, replacing field values and field names during script execution.
Syntax:
Mapping(
loadstatement | selectstatement
)
The mapping prefix can be put in front of aload or a SELECT statement and will store the result of the loading statement as a mapping table. mappingprovides an efficient way to substituting field values during script execution, e.g. replacing US, U.S. or America with USA. A mapping table consists of two columns, the first containing comparison values and the second containing the desired mapping values. mappingtables are stored temporarily in memory and dropped automatically after script execution.
The content of the mapping table can be access using e.g. theMap … Using statement, the Rename Field statement, the Applymap() function or the Mapsubstring() function.
example :
In this example we load a list of salespersons with a country code representing their country of residence. We use a table mapping a country code to a country to replace the country code with the country name. Only three countries are defined in the mapping table, other country codes are mapped to ‘Rest of the world’.
// Load mapping table of country codes:
map1:
mapping load *
Inline [
CCode, country
Sw, Sweden
Dk, Denmark
No, Norway
] ;
// Load list of salesmen, mapping country code to country
// If the country code is not in the mapping table, put Rest of the world
salespersons:
load *,
ApplyMap(‘map1′, CCode,’Rest of the world’) As country
Inline [
CCode, salesperson
Sw, John
Sw, Mary
Sw, Per
Dk, Preben
Dk, Olle
No, Ole
Sf, Risttu] ;
// We don’t need the CCode anymore
Drop Field ‘CCode’;
The resulting table looks like this:
salesperson | country |
---|---|
John | Sweden |
Mary | Sweden |
Per | Sweden |
Preben | Denmark |
Olle | Denmark |
Ole | Norway |
Risttu | Rest of the world |