File Browsing

SetColumnMapping

STD.File.SetColumnMapping( file, mapping );

fileA null-terminated string containing the logical filename.
mappingA null-terminated string containing a comma-delimited list of field mappings.

The SetColumnMapping function defines how the data in the fields of the file must be transformed between the actual data storage format and the input format used to query that data.

The format for each field in the mapping list is:

<field>{set(<transform>( args),...),get(<transform>,...),displayname(<name>)}

<field>The name of the field in the file.
setOptional. Specifies the transforms applied to the values supplied by the user to convert them to values in the file.
<transform>Optional. The name of a function to apply to the value. This is typically the name of a plugin function. The value being converted is always provided as the first parameter to the function, but extra parameters can be specified in brackets after the transform name (similar to SALT hygiene).
getOptional. Specifies the transforms applied to the values in the file to convert them to the formatted values as they are understood by the user.
displaynameOptional. Allows a different name to be associated with the field than the user would naturally understand.

Note that you may mix unicode and string functions, as the system automatically converts the parameters to the appropriate types expected for the functions.

Example:

// A file where the firstname(string) and lastname(unicode) are
//always upper-cased:
// There is no need for a displayname since it isn't really a
// different field as far as the user is concerned, and there is
// obviously no get transformations.
 firstname{set(stringlib.StringToUpperCase)},
                surname{set(unicodelib.UnicodeToUpperCase)}
// A name translated using a phonetic key
// it is worth specifying a display name here, because it will make
// more sense to the user, and the user may want to enter either the
// translated or untranslated names.
 dph_lname{set(metaphonelib.DMetaPhone1),
      displayname(lname)}
// A file where a name is converted to a token using the namelib
// functions.  (I don't think we have an example of this)
// (one of the few situations where a get() attribute is useful)
 fnametoken{set(namelib.nameToToken),
       get(namelib.tokenToName),
       displayname(fname)}
// upper case, and only include digits and alphabetic.
 searchname{set(stringlib.StringToUpperCase,
      stringlib.StringFilter(
        'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'))}
// A file with a field that that needs to remove accents and then
// uppercase:
 lastname{set(unicodeLIb.CleanAccents,stringLib.StringToUpperCase)}