Skip to content

CSVMap

mapping category: mapping-table supports `||` resultSize: N

Maps the input string to a value looked up in an external CSV file by source-column key.

CSVMap looks up the input value in a CSV file registered with the engine, using sourceColumn as the lookup key, and returns the value from destinationColumn of the matching row. CSV files are loaded through the engine's csvmap directory configuration.

CSV columns are stored as strings, so the input must be STRING-typed — use AsString() upstream for numeric or date inputs. When the lookup fails:

  • With a fourth (default) parameter, the default value is returned and successfulMapping is set to false.
  • Without a default, the row is marked unsuccessful so that conditional chaining (||) can fall through to a fallback rule.

CSVMap supports multi-sized results: [] returns every matching row, [N] requires exactly N. With multiple matches, all values are emitted as additional results.

Parameters

1file Mandatory — accepts: STRING

Name of the CSV file relative to the directory pointed to by the csvmap directory clause in etl.conf.

2sourceColumn Mandatory — accepts: STRING

Header name of the column to look up the input value against.

3destinationColumn Mandatory — accepts: STRING

Header name of the column whose value is returned on match.

4default Optional — accepts: STRING, NULL

Default value used when no match is found. Without this parameter, unmatched rows are marked unsuccessful so that ||-chains can take over.

Input type

  • STRING

Output type

  • STRING

Requires

  • The CSV file must be registered under the configured csvmap directory.
  • Allows multi-sized results.

Examples

Single-result lookup with default (test064)

CSVMap("lookup.csv", "code", "description", "MISSING")

Multi-result lookup, unlimited

CSVMap("multi_lookup.csv", "group_code", "member_name", "MISSING")[]

Conditional chaining onto a Map fallback

CSVMap("multi_lookup.csv", "member_id", "member_name") ||
Map([["This", "is"], ["not", "used"]], "MISSING")

Errors

  • CSVMap cannot handle a null value as input
    A NULL reached the rule and no default value is configured.
  • The fileX' doesn't exist in the csvmap directory`
    The CSV file is missing or not registered with the engine.
  • CSVMap requires STRING input
    A non-STRING input field was used. Convert with AsString() first.
  • CSVMap accepts three to four parameters
    Wrong arity or non-string parameter type.

See also

Map, ValueMap, UsagiMap, VocabMap